Re: Xlogprefetcher: Use atomic add for increment counter

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Xlogprefetcher: Use atomic add for increment counter
Date: 2025-11-07 15:03:01
Message-ID: CAEudQAqY17xcE9+hF8gG4TaD67_PjU1B6xp2zPbHFgTMS5qHmA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sex., 7 de nov. de 2025 às 11:59, Andres Freund <andres(at)anarazel(dot)de>
escreveu:

> On 2025-11-07 11:52:37 -0300, Ranier Vilela wrote:
> > Em sex., 7 de nov. de 2025 às 11:41, Andres Freund <andres(at)anarazel(dot)de>
> > escreveu:
> > > On 2025-11-07 11:28:06 -0300, Ranier Vilela wrote:
> > > > Use pg_atomic_fetch_add_u64 to replace pg_atomic_read_u64 and
> > > > pg_atomic_write_u64 calls.
> > > >
> > > > This simplifies the logic and this increases the likelihood that the
> > > > operation will be successful.
> > >
> > > How does it do so? As the assertions indicate, this can only be run
> from a
> > > single process.
> > >
> > Can I rephrase that?
> >
> > That simplifies the logic a bit.
>
> Maybe simpler, but also vastly slower than before. An atomic increment is
> maybe two orders of magnitude more expensive than an unlocked read & write.
>
Seriously, I didn't know.

It's best to withdraw the patch then.
Thanks for clarifying this.

best regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-11-07 15:03:03 Re: Consistently use the XLogRecPtrIsInvalid() macro
Previous Message Andres Freund 2025-11-07 14:59:04 Re: Xlogprefetcher: Use atomic add for increment counter