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

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Andres Freund <andres(at)anarazel(dot)de>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)
Date: 2025-12-17 09:25:50
Message-ID: c00d4a9f-c0f8-49ca-bf27-29c6641f2fc6@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/12/2025 02:47, Andres Freund wrote:
> On 2025-11-25 11:54:00 -0500, Andres Freund wrote:
>> Thanks a lot for that detailed review! A few questions and comments, before I
>> try to address the comments in the next version.
>
> Here's that new new version, with the following changes
>
> - Some more micro-optimizations, most importantly adding a commit that doesn't
> initialize the delay in LockBufHdr() unless needed. With those I don't see a
> consistent slowdown anymore (slight speedup on one workstation, slight
> slowdown on another, in an absurdly adverse workload)

+1

I'm comparing the patched LockBufHdr() with LWLockWaitListLock(), which
does pretty much the same thing, and LWLockWaitListLock() already did
the initialization of the delay that way. But there are some small
differences:

- LockBufHdr() uses unlikely() in the initial attempt,
LWLockWaitListLock() does not
- LWLockWaitListLock() uses pg_atomic_read_u32() after spinning,
LockBufHdr() retries directly with pg_atomic_fetch_or_u32().

Are there reasons for the differences, or is it just that they were
developed separately and ended up looking slightly different?

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message GRANT ZHOU 2025-12-17 09:32:39 Re: Improve logical replication usability when tables lack primary keys
Previous Message Bertrand Drouvot 2025-12-17 09:24:31 Re: Fix and improve allocation formulas