Re: Buffer Cache Problem - Mailing list pgsql-hackers

From jacktby jacktby
Subject Re: Buffer Cache Problem
Date
Msg-id 124274C8-E6E6-42C3-980C-4B25D19C2CD1@gmail.com
Whole thread Raw
In response to Re: Buffer Cache Problem  (jacktby jacktby <jacktby@gmail.com>)
List pgsql-hackers
Hi, I have 3 questions here:
1. I see comments in but_internals.h below:
========================================
 * Also, in places we do one-time reads of the flags without bothering to
 * lock the buffer header; this is generally for situations where we don't
 * expect the flag bit being tested to be changing.
========================================
In fact, the flag is in state filed which is an atomic_u32, so we don’t need to acquire buffer header lock in any case, but for this comment, seems it’s saying we need to hold a buffer header lock when read flag in general.

2. Another question:
========================================
 * We can't physically remove items from a disk page if another backend has
 * the buffer pinned.  Hence, a backend may need to wait for all other pins
 * to go away.  This is signaled by storing its own pgprocno into
 * wait_backend_pgprocno and setting flag bit BM_PIN_COUNT_WAITER.  At present,
 * there can be only one such waiter per buffer.
========================================
The comments above,  in fact for now, if a backend plan to remove items from a disk page, this is a mutation operation, so this backend must hold a exclusive lock for this buffer page, then in this case, there are no other backends pinning this buffer, so the pin refcount must be 1 (it’s by this backend), then this backend can remove the items safely and no need to wait other backends (because there are no other backends pinning this buffer). So my question is below:
 The operation “storing its own pgprocno into
 * wait_backend_pgprocno and setting flag bit BM_PIN_COUNT_WAITER” is whether too expensive, we should not do like this, right?

3. Where is the array?
========================================
 * Per-buffer I/O condition variables are currently kept outside this struct in
 * a separate array.  They could be moved in here and still fit within that
 * limit on common systems, but for now that is not done.
========================================

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock
Next
From: Andres Freund
Date:
Subject: Re: AdvanceXLInsertBuffers() vs wal_sync_method=open_datasync