From: | Evgeny Voropaev <evgeny(dot)voropaev(at)tantorlabs(dot)com> |
---|---|
To: | Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, 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-18 09:02:42 |
Message-ID: | 5e758f54-65cb-4bbb-b80f-8448d905c614@tantorlabs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 17.02.2025 21:00, Álvaro Herrera wrote:
> On 2025-Feb-17, Andrey Borodin wrote:
>
>> BootStrapSlruPage() always calls zerofunc(pageno, false) with second argument false.
>> In case of every possible argument (ZeroCLOGPage, ZeroCommitTsPage,
>> ZeroMultiXactOffsetPage, ZeroMultiXactMemberPage, ZeroSUBTRANSPage) it
>> means just a call to SimpleLruZeroPage().
>> I think we can safely replace
>>
>> + slotno = (*zerofunc)(pageno, false);
>>
>> with
>>
>> + slotno = SimpleLruZeroPage(pageno);
>>
>> Thus we will not need zerofunc argument at all.
>
> Good observation. This also suggests another change: because this new
> function is used not only for bootstrapping but also during WAL replay,
> we can call the new function SimpleLruUnloggedZeroPage() and place it
> immediately after SimpleLruZeroPage, instead of at the end of the file.
>
Created functions BootStrapSlruPage,SimpleLruZeroAndLogPage,
WriteSlruZeroPageXlogRec. Using of these functions allows to delete
ZeroXYZPage functions, WriteXYZZeroPageXlogRec functions and eliminate
code repetitions.
The conception is:
/*
* BootStrapSlruPage,
* SimpleLruZeroAndLogPage,
* SimpleLruZeroPage
* - functions nullifying SLRU pages.
*
* BootStrapSlruPage is the most holistic. It performs:
* 1. locking,
* 2. nullifying,
* 3. logging (when writeXlog is true),
* 4. writing out,
* 5. releasing the lock.
*
* SimpleLruZeroAndLogPage performs:
* 2. nullifying,
* 3. logging (when writeXlog is true),
* 4. writing out.
*
* If the writeXlog is true, BootStrapSlruPage and SimpleLruZeroAndLogPage
* emit an XLOG record saying we did this.
* If the writeXlog is false, the rmid and info parameters are unused.
*
* SimpleLruZeroPage performs:
* 2. nullifying.
*/
Attachment | Content-Type | Size |
---|---|---|
v3-0001-Elimination-of-the-repetitive-code-at-the-SLRU-bo.patch | text/x-patch | 18.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2025-02-18 09:12:44 | Commitfest Manager for March |
Previous Message | vignesh C | 2025-02-18 08:54:23 | Re: Add an option to skip loading missing publication to avoid logical replication failure |