Hi,

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.

GenSlab
-------
Fixed a bunch of bugs that made GenSlab utterly useless. Firstly, chunkSize was not stored in GenSlabContextCreate(), so this check in SlabAlloc()

    if (size <= set->chunkSize)
        return MemoryContextAlloc(set->slab, set->chunkSize);
    else
        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 etc.)

- 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.

regards

--
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment: slab-allocators-v3.tgz
Description: application/compressed-tar

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to