Re: Skip prefetch for block references that follow a FPW or WILL_INIT of the same block

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: Ethan Mertz <ethan(dot)mertz(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
Subject: Re: Skip prefetch for block references that follow a FPW or WILL_INIT of the same block
Date: 2026-10-14 10:47:28
Message-ID: CAE9k0Pkhi-A7A+SOkXbZpMCzP4_q7d3smahwKJHndQYj3n2HHg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, Jun 5, 2026 at 1:37 AM Ethan Mertz <ethan(dot)mertz(at)gmail(dot)com> wrote:
>
> The following review has been posted through the commitfest application:
> make installcheck-world: tested, passed
> Implements feature: tested, passed
> Spec compliant: tested, passed
> Documentation: tested, passed
>
> Hi Satya,
>
> I reviewed the v2 patch (0001-xlogprefetcher-record-FPW-WILL_INIT-...).
>
> Applied cleanly to current HEAD, built with --enable-cassert and
> --enable-debug, make check and make installcheck pass.
>
> > Fixed this by making these blocks as recently seen in the FPW and WILL_INIT
> > skip paths. The existing duplicate-check loop then naturally suppresses
> > prefetch attempts for subsequent references to the same block, counting
> > them under the skip_rep stat.
>
> The approach integrates cleanly into the existing prefetch infrastructure
> reusing the recently-seen window for deduplication rather than adding new
> tracking state is a nice design choice.
>
> I also agree with the choice to add this logic to init and fpw records but not the
> filtered pages because these may still be beneficial to read later in the window.
>
> I read through the code and it looks correct to me. One minor nit: there's
> an extra blank line added just before lrq_complete_lsn that seems unrelated
> to the change. Removing this would keep the diff focused.
>

I have also looked into the patch and the fix indeed looks good and so
does the impact as explained by Satya in his initial email [1] and
Valeriy Degtyarev at [2]. The attached patch removes the unrelated
blank line that was added in XLogPrefetcherReadRecord(), which
detached the "All IO initiated by earlier WAL is now completed"
comment from the lrq_complete_lsn() call it describes.

[1] - https://www.postgresql.org/message-id/CAHg%2BQDf%3DeFFnOvmaPJQrXNiXaTOhhJhvO%3DDzmVUi%3DVGFRh5B0A%40mail.gmail.com
[2] - https://www.postgresql.org/message-id/CAAi_3tJsH5UOHLrHJ_YNYC1R-1arg%2BLNoKJPZhaVphPvjhQ%2Bew%40mail.gmail.com

--
With Regards,
Ashutosh Sharma.

Attachment Content-Type Size
v3-0001-xlogprefetcher-record-FPW-WILL_INIT-blocks-in-recent.patch application/octet-stream 3.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Matthias Dötsch 2026-10-14 10:36:49 Perf: Specialize ExecIndexOnlyScan() like ExecSeqScan()