postgres-github.git / summary / log / commit / refs

commit    9fe9ecd516b09434df59d6e7396d508f9c4477c8
Author:   Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date:     Fri Apr 03 23:40:25 2026 +0000

    Allocate all parts of shmem hash table from a single contiguous area
    
    Previously, the shared header (HASHHDR) and the directory were
    allocated by the caller, and passed to hash_create(), while the actual
    elements were allocated separately with ShmemAlloc(). After this
    commit, all the memory needed by the header, the directory, and all
    the elements is allocated using a single ShmemInitStruct() call, and
    the different parts are carved out of that allocation. This way the
    ShmemIndex entries (and thus pg_shmem_allocations) reflect the size of
    the whole hash table, rather than just the directories.
    
    Commit f5930f9a98 attempted this earlier, but it had to be reverted.
    The new strategy is to let dynahash.c perform all the allocations with
    the alloc function, but have the alloc function carve out the parts
    from the one larger allocation. The shared header and the directory
    are now also allocated with alloc calls, instead of passing the area
    for those directly from the caller.
    
    Reviewed-by: Tomas Vondra <tomas@vondra.me>
    Discussion: https://www.postgresql.org/message-id/01ab1d41-3eda-4705-8bbd-af898f5007f1@iki.fi

[parent: 999e9ebb51c9]