Figuring out shared buffer pressure

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Figuring out shared buffer pressure
Date: 2012-05-30 16:56:02
Message-ID: 20120530165602.GA26894@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

As part of a blog, I started looking at how a user could measure the
pressure on shared buffers, e.g. how much are they being used, recycled,
etc.

They way you normally do it on older operating systems is to see how
many buffers on the free list (about to be reused) are reclaimed as
needed --- that usually indicates kernel cache pressure. Unfortunately,
we don't have a freelist, except for initial assignment of shared
buffers on startup.

I then started looking at pg_buffercache, and thought perhaps the
'usagecount' column could give me a way of measuring this. For example,
excessive scanning of the shared buffers for replaceable buffers would
indicate pressure, which might show as a low usagecount.

I ran the attached SQL script, and got the attached results. You can
see that the first few attempts to use many shared buffers was thwarted
by our GetAccessStrategy() function that prevent sequential access from
blowing away other shared buffers, limiting such scans to 256k:

http://doxygen.postgresql.org/freelist_8c_source.html#l00410

Our storage/buffers/README file has the reason for the size (to fit in
CPU cache), line 204:

http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/storage/buffer/README

I realize we can't size this based on shared buffers because it is based
on the CPU cache size, but it seems we are purposely storing buffers in
the kernel rather than shared buffers in this case. I suppose if we
allowed a table to use more, there would be no way to keep all the
memory in a single 256k area, but are we sure this is the right
approach?

Based on what I found, I can see no way users can see how heavily their
shared buffers are being used. Is that correct?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
bufcache.sql text/plain 1.1 KB
bufcache.out text/plain 2.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergey Koposov 2012-05-30 16:58:02 Re: 9.2beta1, parallel queries, ReleasePredicateLocks, CheckForSerializableConflictIn in the oprofile
Previous Message Ants Aasma 2012-05-30 16:43:22 Re: slow dropping of tables, DropRelFileNodeBuffers, tas