Re: [HACKERS] PATCH: two slab-like memory allocators
От | Andres Freund |
---|---|
Тема | Re: [HACKERS] PATCH: two slab-like memory allocators |
Дата | |
Msg-id | 20170224221038.43xf2cyonczzr6hb@alap3.anarazel.de обсуждение исходный текст |
Ответ на | Re: [HACKERS] PATCH: two slab-like memory allocators (Tomas Vondra <tomas.vondra@2ndquadrant.com>) |
Ответы |
Re: [HACKERS] PATCH: two slab-like memory allocators
|
Список | pgsql-hackers |
Hi, On 2017-02-21 01:43:46 +0100, Tomas Vondra wrote: > Attached is v9 of this patch series. This addresses most of the points > raised in the review, namely: Cool, thanks. > 3) get rid of the block-level bitmap tracking free chunks > > Instead of the bitmap, I've used a simple singly-linked list, using int32 > chunk indexes. Perhaps it could use the slist instead, but I'm not quite > sure MAXALIGN is guaranteed to be greater than pointer. I'm pretty sure it's guaranteed to be >= sizeof(void*). But this seems ok, so ... Attached are changes I made on the path to committing the patch. These look large enough that I wanted to give you a chance to comment: - The AllocFreeInfo changes aren't correct for 32bit systems with 64bit, longs (like linux, unlike windows) - using %zu is better (z is code for size_t sized) - Split off the reorderbuffer changes - Removed SlabBlock/SlabChunk / renamed SlabBlockData - +#ifdef MEMORY_CONTEXT_CHECKING +#define SLAB_CHUNK_USED \ + (offsetof(SlabChunkData, requested_size) + sizeof(Size)) +#else doesn't work anymore, because requested_size isn't a top-level field. I first redefined it as (without surrounding ifdef) #define SLAB_CHUNK_USED \ (offsetof(SlabChunkData, header) + sizeof(StandardChunkHeader)) but I'm not really sure there's a whole lot of point in the define rather than just using sizeof() on the whole thing - there's no trailing padding? - SLAB_CHUNK_PUBLIC and SLAB_BLOCKHDRSZ are unused? - renamed 'set' variables (and comments) to slab. - used castNode(SlabContext, context) instead of manual casts - I rephrased + * + * We cache indexes of the first empty chunk on each block (firstFreeChunk), + * and freelist index for blocks with least free chunks (minFreeChunks), so + * that we don't have to search the freelist and block on every SlabAlloc() + * call, which is quite expensive. so it's not referencing firstFreeChunk anymore, since that seems to make less sense now that firstFreeChunk is essentially just the head of the list of free chunks. - added typedefs.list entries and pgindented slab.c - "mark the chunk as unused (zero the bit)" referenced non-existant bitmap afaics. - valgrind was triggering on block->firstFreeChunk = *(int32 *) SlabChunkGetPointer(chunk); because that was previously marked as NOACCESS (via wipe_mem). Explicitly marking as DEFINED solves that. - removed * XXX Perhaps we should not be gentle at all and simply fails in all cases, * to eliminate the (mostly pointless) uncertainty. - you'd included MemoryContext tup_context; in 0002, but it's not really useful yet (and the comments above it in reorderbuffer.h don't apply) - SlabFreeInfo/SlabAllocInfo didn't actually compile w/ HAVE_ALLOCINFO defined (pre StandardChunkHeader def) - some minor stuff. I'm kinda inclined to drop SlabFreeInfo/SlabAllocInfo. I've not yet looked a lot at the next type of context - I want to get this much committed first... I plan to give this another pass sometime this weekend and then push soon. - Andres -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
В списке pgsql-hackers по дате отправления: