David Rowley of Postgres Committed a critical change aimed at improving PostgreSQL performance and reduce memory management overhead. This move reduces the chunk header size from 16 bytes to 8 bytes:
The changes made here reduce the chunk header size to just 8 bytes for all 3 of our memory context types. For small to medium allocations, this significantly increases the number of chunks we can put on a given chunk, making memory more efficient.
Additionally, this commit overhauls the rule that pointers to palloc memory must be directly prefixed with a pointer to the owning memory context; instead, we now insist that they be directly prefixed with an 8-byte value, with the least significant 3 bits set is a value to indicate what type of memory context the pointer belongs to. Using these 3 bits as an index (called MemoryContextMethodID) to a new array storing methods for each memory context type, we can now pass pointers to a given function (eg pfree() and repalloc() ) to implementations specific to that context functions to allow them to design their own methods to find the memory context that owns a given allocated memory block.
See this commit for more details.
Phoronix noted that in earlier discussions around reducing PostgreSQL memory overhead, Rowley achieved a 17% reduction in read-only simple workloads on Ryzen Threadripper workstationsThroughputPerformance improvements.
“When this memory overhead reduction first appears in a stable PostgreSQL release, it will certainly be interesting to see how it helps in the real world. However, since PostgreSQL 15 has been forked ahead of its release later this year, it is expected that This change won’t appear until PostgreSQL 16.”
#PostgreSQL #plans #optimize #performance #reduce #memory #management #overhead