Re: Throwing away unnecessary spin-locks

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, shihao zhong <zhong950419(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Throwing away unnecessary spin-locks
Date: 2026-10-02 17:14:13
Message-ID: CAHyXU0yEAk184baUAb-K+dV3eQ2D2gkTkPRKvLrtg4zusmYQSw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 2, 2026 at 11:02 AM Alexandre Felipe <
o(dot)alexandre(dot)felipe(at)gmail(dot)com> wrote:

>
> Trying to find your snippet, is this the one?
>

yeah, there was a copy/paste error, sorry about that

> 1262 ReserveXLogSwitch(XLogRecPtr *StartPos, XLogRecPtr *EndPos,
> XLogRecPtr *PrevPtr)
> 1263 {
> 1278 SpinLockAcquire(&Insert->insertpos_lck);
> 1280 startbytepos = Insert->CurrBytePos;
> 1282 ptr = XLogBytePosToEndRecPtr(startbytepos);
> 1290 endbytepos = startbytepos + size;
> 1303 Insert->CurrBytePos = endbytepos;
> 1306 SpinLockRelease(&Insert->insertpos_lck);
>
> This illustrates well the cases where things can't be written without a
> lock.
> atomically. Because changes between line 1280 and line 1303 are rolled
> back.
>
> However, this particular example doesn't stop us from reading because it
> will either
> CurBytePos before line 1303, and that is the same as reading under a lock
> before that
> block, or after the line 1303 and that is equivalent to reading under a
> lock after that block.
>

ok, sure. This is a bit above my pay grade :-). I guess the point is to
work backward from those kinds of points, measure contention, and show the
benefit.

merlin

>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Manu 2026-10-02 17:18:00 Re: BUG #19686: Rolling back SET TABLESPACE
Previous Message Alexandre Felipe 2026-10-02 17:06:39 Re: BUG #19686: Rolling back SET TABLESPACE