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

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Tomas Vondra <tomas(at)vondra(dot)me>
Cc: Jeremy Schneider <schneider(at)ardentperf(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Lakshmi N <lakshmin(dot)jhs(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-28 01:13:42
Message-ID: CAGRkXqSFFN1KFtwiS3r5Anky6j0XGtr3-VWnaG9DzGM8Dbsw-Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tomas,

Thanks for the test script, I repro the same thing as you posted, and the
request size seems to just follow the fadvise range.

> I don't have a great solution to this. We'd need to do I/O combining,
> similarly to what happens on the primary. I'm not sure if it's feasible,
> or if it'd be better to rework the prefetcher to use read_stream (which
> has all of this built in).

Merging adjacent blocks into one smgrprefetch() call in the prefetcher
would be a small fix. But it is still only advice, so it does not help
io_direct. It also cannot merge across other relations.

I would rather move to AIO, then we do not need to change
this code in the future. But there are few interesting issues in my mind

1. WAL mixes many relations, so need to have multiple read streams
2. Redo may need to takes a cleanup lock... and prefetcher could also
pinned it, so we may need to change CheckBufferIsPinnedOnce()?

Maybe the right way is to implement a new API for redo or just use
Start/WaitReadBuffers()? WDYT?

Thanks,
Shihao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-10-28 01:28:37 Return INT_MAX or INT_MIN from strtoint() on overflow
Previous Message Amit Langote 2026-10-28 00:42:18 multi-row INSERT broken with a sublink in a target column subscript