Re: Small WAL replay perf improvements (smgropen()+reduce membarriers for LSN waiters)

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Small WAL replay perf improvements (smgropen()+reduce membarriers for LSN waiters)
Date: 2026-11-30 08:04:49
Message-ID: CABPTF7XOVQuk5KNJfib1UCXsMDYLJbf+gdkOPB9CZnQ3mxxvsA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jakub,

> There's even third thing that surpised me: I've noticed there's new code from
> PG 19 onwards (WAIT FOR LSN), and this seems to be (?) slowing us down too
> potentially (by how much I don't haven't measured from last version PG18 vs
> PG19), but we seem to do now 3x separate pg_atomic_read_membarrier_u64()
> from the main redo loop (PerformWalRecovery()), so quick attempted to do just
> one read barrier read seems to work and there gives some boost too. But I
> haven't tested this on like ARM (where without such barriers CPUs are more
> free to reoder stuff - right?), so I just hope it's safe (it's first time
> for me to play with barrier(s), maybe better one could be used there, dunno).
> Other interesting thing (not pursued covered in patch) is perhaps why do
> we even check for the WaitLSNWakeups() in case of doing pure (closed) crash
> recovery (when DB is inaccessible, way before anything could issue register
> to be waiting for anything)?

Thanks for your observation. This has been raised and disussed before,
but not tackled yet [1][2]. I think we also need to move the new
helper inside ApplyWalRecord() as Heikki suggested.

[1] https://www.postgresql.org/message-id/CAPpHfdvu7bPzP1p3eZW3t6QgF39stTce=OyObyn6N2J+ZC5Khw@mail.gmail.com
[2] https://www.postgresql.org/message-id/CABPTF7UkddAnG=6X0JLHEOVWO-xoG3XYXgc1uWhbjj5eHRjipw@mail.gmail.com

--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jakub Wartak 2026-11-30 08:24:04 Re: log XLogPrefetch stats at end of recovery
Previous Message Pavel Stehule 2026-11-30 07:53:17 extremely slow planner when DISTINCT clause holds more columns