pgsql: Refactor some repetitive SLRU code

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor some repetitive SLRU code
Date: 2025-07-07 14:54:49
Message-ID: E1uYnF3-0057wB-0Q@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Refactor some repetitive SLRU code

Functions to bootstrap and zero pages in various SLRU callers were
fairly duplicative. We can slash almost two hundred lines with a couple
of simple helpers:

- SimpleLruZeroAndWritePage: Does the equivalent of SimpleLruZeroPage
followed by flushing the page to disk
- XLogSimpleInsertInt64: Does a XLogBeginInsert followed by XLogInsert
of a trivial record whose data is just an int64.

Author: Evgeny Voropaev <evgeny(dot)voropaev(at)tantorlabs(dot)com>
Reviewed by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reviewed by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Reviewed by: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/97820ce8-a1cd-407f-a02b-47368fadb14b%40tantorlabs.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c61678551699610d658edb0ae838d2541688caba

Modified Files
--------------
src/backend/access/transam/clog.c | 67 ++----------------
src/backend/access/transam/commit_ts.c | 66 +++---------------
src/backend/access/transam/multixact.c | 120 ++++----------------------------
src/backend/access/transam/slru.c | 25 +++++++
src/backend/access/transam/subtrans.c | 34 ++-------
src/backend/access/transam/xloginsert.c | 12 ++++
src/include/access/slru.h | 1 +
src/include/access/xloginsert.h | 1 +
8 files changed, 71 insertions(+), 255 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-07-07 18:34:54 pgsql: Restore the ability to run pl/pgsql expression queries in parall
Previous Message Álvaro Herrera 2025-07-07 12:00:21 pgsql: Standardize LSN formatting by zero padding