Re: Elimination of the repetitive code at the SLRU bootstrap functions.

From: Evgeny <evorop(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Evgeny Voropaev <evgeny(dot)voropaev(at)tantorlabs(dot)com>
Cc: x4mmm(at)yandex-team(dot)ru, aleksander(at)timescale(dot)com, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Elimination of the repetitive code at the SLRU bootstrap functions.
Date: 2025-02-24 05:42:54
Message-ID: 57af7397-e436-48b1-a449-fb4012ce1cc1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello hackers!

> I think the overall idea here is good, but I didn't like the new
> WriteSlruZeroPageXlogRec helper function; it looks too much like a
> modularity violation (same for the fact that you have to pass the rmid
> and info from each caller into slru.c). I would not do that in slru.c
> but instead in every individual caller, and have this helper function in
> xloginsert.c where it can be caller XLogSimpleInsert or something like
> that.

Thank you Alvaro! I got your ideas and have tried to implement them.

In the v4 patch version:
1) WriteSlruZeroPageXlogRec has been renamed into XLogSimpleInsert and
moved to the xloginset.c.

2) With the purpose of excluding passing any resource manager’s
information into the slru.c module I propose to pass into the
BootStrapSlruPage the XLogInsertFunc parameter pointing to a function
accomplishing insertion of an XLog record. Implementations of these
functions are enclosed in a corresponding slru-page module (commit_ts.c,
multixaxt.c and so on). It preserves original modularity - the
BootStrapSlruPage and the slru.c still do not know anything about
resource managers. If the XLogInsertFunc parameter equals zero,
BootStrapSlruPage will not try to perform XLog recording.

3) In addition, let’s also implement in the BootStrapSlruPage a new
parameter writePage. It commands whether to write a page onto a disk or
not. As a result, the BootStrapSlruPage become apt to be used in a
larger number of places of code.

> Also, please do not document a bunch of functions together in a single
> comment. Instead, have one comment for each function.
> This is not our style, and I don't think it's very ergonomical.

I got it. And since
4) The SimpleLruZeroAndLogPage is subject to deletion now.
comments are formatted as well.

> sometimes I read source from bottom to top
Probably, we all should profess this approach!

Best regards,
Evgeny Voropaev,
Tantor Labs LLC.

Attachment Content-Type Size
v4-0001-Elimination-of-the-repetitive-code-at-the-SLRU-bo.patch text/x-patch 21.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2025-02-24 06:22:15 Re: psql \dh: List High-Level (Root) Tables and Indexes
Previous Message Amit Kapila 2025-02-24 05:27:22 Re: Adding a '--two-phase' option to 'pg_createsubscriber' utility.