| From: | Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com> |
|---|---|
| To: | Xuneng Zhou <xunengzhou(at)gmail(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 09:16:29 |
| Message-ID: | CAKZiRmySfHgXmtEwr5emQicb-MSY0p8Oj=0VEcX1Jv4qt3Kyhg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Nov 30, 2026 at 9:05 AM Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
>
> 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
Hi Xuneng,
thanks for Your's work on WAIT FOR LSN. I wasn't aware of this subthread,
which is my fault as I could search for it first :) -- instead I've just tried
simplest optimization as fun experiment (2-4% is not nothing). Anyway I was
just tresspasing this code and happened to notice this stuff accidently, and
I don't have urge to fix it the most optimal way: so the question is do you
want to carry on with longer term plans to of using "hierarchy idea" [2] or
not? (I could just help to bench it there)
Or maybe we could just to stick Heikki's suggested way [1] that once it's
after directly after SpinLockRelase() we could even get rid of this memory
barrier totally(?), but the earlier commit a80a593ab6 / [3] make me feel
hacking around this is preeeety risky thing, especially as I do not have
reodering CPUs at a hand to test it, but that should be OK (?)
-J.
[1] - https://www.postgresql.org/message-id/e4e98e40-40d5-4d53-85de-6c456c2b301a%40iki.fi
[2] - https://www.postgresql.org/message-id/CAPpHfdvu7bPzP1p3eZW3t6QgF39stTce%3DOyObyn6N2J%2BZC5Khw%40mail.gmail.com
[3] - https://www.postgresql.org/message-id/zqbppucpmkeqecfy4s5kscnru4tbk6khp3ozqz6ad2zijz354k%40w4bdf4z3wqoz
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-11-30 09:52:57 | Re: Preserve conflict log table during upgrade |
| Previous Message | Kirill Reshke | 2026-11-30 08:57:55 | Re: NOT-IN to ANTI-JOIN conversation changes query result |