From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | Evgeny Voropaev <evgeny(dot)voropaev(at)tantorlabs(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Elimination of the repetitive code at the SLRU bootstrap functions. |
Date: | 2025-02-13 12:05:19 |
Message-ID: | CAJ7c6TNLLAL16ySqmRE3VG_ehHFkyEqceLsa4nY2bRwdEpCsPw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Evgeny,
> The functions, bootstrapping SLRU pages, such as BootStrapMultiXact,
> BootStrapCLOG, ActivateCommitTs, multixact_redo and others, have a lot
> of repetitive code.
>
> A new proposed function BootStrapSlruPage moves a duplicating code into
> the single place. Additionally, a new member ZeroFunc is implemented in
> the SlruCtlData structure. The ZeroFunc keeps a pointer to a function
> proper for nullifying SLRU pages of a type defined by a corresponding
> SlruCtlData object.
>
> Applying proposed modifications can simplify maintenance and future
> development of Postgres code in the realm of bootstrapping SLRU.
Thanks for the patch.
```
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -102,14 +102,6 @@ TransactionIdToPage(TransactionId xid)
*/
#define THRESHOLD_SUBTRANS_CLOG_OPT 5
-/*
- * Link to shared-memory data structures for CLOG control
- */
-static SlruCtlData XactCtlData;
-
-#define XactCtl (&XactCtlData)
-
-
static int ZeroCLOGPage(int64 pageno, bool writeXlog);
static bool CLOGPagePrecedes(int64 page1, int64 page2);
static void WriteZeroPageXlogRec(int64 pageno);
@@ -130,6 +122,14 @@ static void
TransactionIdSetPageStatusInternal(TransactionId xid, int nsubxids,
XLogRecPtr lsn, int64 pageno);
+/*
+ * Link to shared-memory data structures for CLOG control
+ */
+static SlruCtlData XactCtlData = { .ZeroPage = ZeroCLOGPage };
+
+#define XactCtl (&XactCtlData)
+
+
```
Since BootStrapSlruPage() is the only caller of ZeroPage() it seems to
me that it merely wastes space in SlruCtlData. On top of that I'm not
100% sure if all the supported platforms have C99 compilers with
designated initializers support. Wouldn't it be simpler to pass the
callback straight to BootStrapSlruPage()?
After changing the patch accordingly it shouldn't move XactCtl and
others. This is just an irrelevant change.
--
Best regards,
Aleksander Alekseev
From | Date | Subject | |
---|---|---|---|
Next Message | Shlok Kyal | 2025-02-13 12:05:56 | Re: Adding a '--clean-publisher-objects' option to 'pg_createsubscriber' utility. |
Previous Message | Álvaro Herrera | 2025-02-13 11:57:03 | Re: NOT ENFORCED constraint feature |