mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Make backend local tracking of buffer pins memory efficient.
Since the dawn of time (aka Postgres95) multiple pins of the same buffer by one backend have been optimized not to modify the shared refcount more than once. This optimization has always used a NBuffer sized array in each backend keeping track of a backend's pins. That array (PrivateRefCount) was one of the biggest per-backend memory allocations, depending on the shared_buffers setting. Besides the waste of memory it also has proven to be a performance bottleneck when assertions are enabled as we make sure that there's no remaining pins left at the end of transactions. Also, on servers with lots of memory and a correspondingly high shared_buffers setting the amount of random memory accesses can also lead to poor cpu cache efficiency. Because of these reasons a backend's buffers pins are now kept track of in a small statically sized array that overflows into a hash table when necessary. Benchmarks have shown neutral to positive performance results with considerably lower memory usage. Patch by me, review by Robert Haas. Discussion: 20140321182231.GA17111@alap3.anarazel.de
This commit is contained in:
@ -37,7 +37,7 @@ typedef struct
|
||||
/*
|
||||
* An int32 is sufficiently large, as MAX_BACKENDS prevents a buffer from
|
||||
* being pinned by too many backends and each backend will only pin once
|
||||
* because of bufmgr.c's PrivateRefCount array.
|
||||
* because of bufmgr.c's PrivateRefCount infrastructure.
|
||||
*/
|
||||
int32 pinning_backends;
|
||||
} BufferCachePagesRec;
|
||||
|
Reference in New Issue
Block a user