|From:||Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>|
|To:||John Gorman <johngorman2(at)gmail(dot)com>|
|Cc:||Petr Jelinek <petr(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: PATCH: two slab-like memory allocators|
|Views:||Raw Message | Whole Thread | Download mbox|
attached is v3 of the patches, with a few minor fixes in Slab, and much
larger fixes in GenSlab.
Slab (minor fixes)
- Removed the unnecessary memset() of new blocks in SlabAlloc(),
although we still need to zero the free bitmap at the end of the block.
- Renamed minFreeCount to minFreeChunks, added a few comments explaining
why/how firstFreeChunk and minFreeChunks are maintained.
- Fixed / improved a bunch of additional comments, based on feedback.
Fixed a bunch of bugs that made GenSlab utterly useless. Firstly,
chunkSize was not stored in GenSlabContextCreate(), so this check in
if (size <= set->chunkSize)
return MemoryContextAlloc(set->slab, set->chunkSize);
return MemoryContextAlloc(set->aset, size);
always fell through to the set->aset case, not allocating stuff in the
Slab at all.
Secondly, nallocations / nbytes counters were not updated at all, so the
Slab was never recreated, so GenSlab was not really generational.
This only affected 1 of 3 contexts in ReorderBuffer, but apparently
those "important ones" to affect performance.
Both issues are fixed in the attached v3, which also introduces two
additional improvements discussed in this thread:
- The chunk size is limited by ALLOCSET_SEPARATE_THRESHOLD, as for large
chunks AllocSet works just fine (thanks to keeping them out of free list
- Instead of specifying blockSize and chunkSize, GenSlabCreate() now
accepts three parameters - minBlockSize, minChunkCount and chunkSize,
and computes the minimum block size (>= minBlockSize), sufficient to
store minChunkCount chunks, each chunkSize bytes. This works much better
in the auto-tuning scenario.
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
|Next Message||Petr Jelinek||2016-10-05 04:26:43||Re: PATCH: two slab-like memory allocators|
|Previous Message||Dmitry Dolgov||2016-10-05 03:48:51||Re: [PATCH] Generic type subscription|