On Mon, Nov 30, 2026 at 9:05 AM Xuneng Zhou <[email protected]> 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+zc5...@mail.gmail.com > [2] > https://www.postgresql.org/message-id/CABPTF7UkddAnG=6x0jlheovwo-xog3xyxgc1uwhbjj5ehrj...@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
