pgsql: Make backend local tracking of buffer pins memory efficient. - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Make backend local tracking of buffer pins memory efficient.
Date
Msg-id E1XNhO6-0006R3-ND@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4b4b680c3d6d8485155d4d4bf0a92d3a874b7a65

Modified Files
--------------
contrib/pg_buffercache/pg_buffercache_pages.c |    2 +-
src/backend/storage/buffer/buf_init.c         |   39 +--
src/backend/storage/buffer/bufmgr.c           |  418 +++++++++++++++++++++++--
src/include/storage/bufmgr.h                  |   19 --
4 files changed, 391 insertions(+), 87 deletions(-)


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: Update C comment for pg_attribute.attislocal
Next
From: Bruce Momjian
Date:
Subject: pgsql: Again update C comments for pg_attribute.attislocal