Thread

  1. Re: Buffer locking is special (hints, checksums, AIO writes)

    Andres Freund <andres@anarazel.de> — 2025-12-18T17:03:36Z

    Hi,
    
    On 2025-12-17 09:54:32 -0500, Andres Freund wrote:
    > On 2025-12-17 11:25:50 +0200, Heikki Linnakangas wrote:
    > > - LWLockWaitListLock() uses pg_atomic_read_u32() after spinning,
    > > LockBufHdr() retries directly with pg_atomic_fetch_or_u32().
    > 
    > I think here LWLockWaitListLock() is likely right - but it seems like a change
    > to LockBufHdr() that I would probably make in a separate commit?
    
    FWIW, I couldn't come up with a scenario where it makes a performance
    difference - exclusive content locks just aren't *that* frequent. And because
    of that the wait list lock doesn't have similar contention as some non-content
    lwlocks (like XidGenLock). The most extreme workload I could think of was
    pgbench hammering a single sequence across many sessions. While the exclusive
    locks show up in wait events, the buffer header spinlock itself doesn't..
    
    So I'm inclined to not change anything about this for now.
    
    Greetings,
    
    Andres Freund