Hi,
On 2017-02-27 22:57:24 -0500, Tom Lane wrote:
> 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.
It would - it really doesn't need the size, because it's the same for
the whole context, and thereby is a waste of space. Still wondering if
we should band-aid this till that's done.
> 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 boundary here! */
> } AllocSetChunkHeader;
>
> where we'd possibly need some help from configure to implement that inner
> #if condition, but it seems doable enough.
Hm, that should be doable with something like
#if MAXIMUM_ALIGNOF > 4 && SIZEOF_VOID_P == 4
which'd probably be better documentation than a macro that hides this
(arguing internally whether SIZEOF_VOID_P or SIZEOF_SIZE_T) is better.
Working on a patch now, will post but not push tonight.
Greetings,
Andres Freund