Re: [PATCH] Let's get rid of the freelist and the buffer_strategy_lock - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: [PATCH] Let's get rid of the freelist and the buffer_strategy_lock
Date
Msg-id CA+hUKG+LxEPeFdgf22MS9PqB_xsTFNGigkXY2Nd=3cb1sVt-5w@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Let's get rid of the freelist and the buffer_strategy_lock  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
On Sun, Aug 17, 2025 at 4:34 PM Thomas Munro <thomas.munro@gmail.com> wrote:
> Or if you don't like those odds, maybe it'd be OK to keep % but use it
> rarely and without the CAS that can fail.

... or if we wanted to try harder to avoid %, could we relegate it to
the unlikely CLOCK-went-all-the-way-around-again-due-to-unlucky-scheduling
case, but use subtraction for the expected periodic overshoot?

    if (hand >= NBuffers)
    {
        hand = hand < Nbuffers * 2 ? hand - NBuffers : hand % NBuffers;
        /* Base value advanced by backend that overshoots by one tick. */
        if (hand == 0)
            pg_atomic_fetch_add_u64(&StrategyControl->ticks_base, NBuffers);
    }



pgsql-hackers by date:

Previous
From: Corey Huinker
Date:
Subject: Re: someone else to do the list of acknowledgments
Next
From: Michael Paquier
Date:
Subject: Re: Remove Instruction Synchronization Barrier in spin_delay() for ARM64 architecture