Re: [HACKERS] PATCH: two slab-like memory allocators - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] PATCH: two slab-like memory allocators
Date
Msg-id 1240.1488254244@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] PATCH: two slab-like memory allocators  (Andres Freund <andres@anarazel.de>)
Responses Re: [HACKERS] PATCH: two slab-like memory allocators  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> Independently of this, we really should redefine StandardChunkHeader to
> be only the MemoryContext.  There's no need to have size/requested_size
> part of StandardChunkHeader, given there's
> MemoryContextMethods->get_chunk_space().

Yeah, perhaps.  The trick would be to get things laid out so that the 
MemoryContext pointer is always immediately adjacent to the chunk data
(no padding between).

One could imagine redefining aset.c's chunk header along the lines of

typedef struct AllocSetChunkHeader
{   Size        size;             /* size of data space allocated in chunk */
#ifdef MEMORY_CONTEXT_CHECKING   Size        requested_size;   /* original request size */
#if 32-bit-but-maxalign-is-8   Size        padding;          /* needed to avoid padding below */
#endif
#endif   MemoryContext context;        /* owning context */   /* there must not be any padding to reach a MAXALIGN
boundaryhere! */
 
} AllocSetChunkHeader;

where we'd possibly need some help from configure to implement that inner
#if condition, but it seems doable enough.

If the slab allocator would be happier with just a MemoryContext pointer
as chunk header, I think we should push in this direction rather than
invent some short-term hack.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] logical replication access control patches
Next
From: Amit Langote
Date:
Subject: Re: [HACKERS] Partitioned tables and relfilenode