| From: | Jeremy Schneider <schneider(at)ardentperf(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | 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>, Tomas Vondra <tomas(at)vondra(dot)me> |
| Subject: | Re: Skip prefetch for block references that follow a FPW or WILL_INIT of the same block |
| Date: | 2026-10-26 23:24:20 |
| Message-ID: | CA+fnDAYMhuVqAf9rsxMossNTyC1vcEcHBQvs7tkH907UCgsq9g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Oct 26, 2026 at 8:34 AM Jeremy Schneider <schneider(at)ardentperf(dot)com>
wrote:
>
> On the primary, even on v16 and older without io_uring and the read_stream
> API, I suspect postgres is making calls to the OS that allow the linux
> kernel to detect sequential reads and perform OS readahead.
>
> I haven't spent much time with Linux kernel source code but AI is telling
> me that POSIX_FADV_WILLNEED (used in fd.c FilePrefetch) explicitly does not
> work with Linux OS level read-ahead.
>
> ...
>
> /*
> * standalone, small random read
> * Read as is, and do not pollute the readahead state.
> */
> do_page_cache_ra(ractl, req_size, 0);
>
> ...
>
> Might be worth some testing to see if OS readahead is happening on
> replicas when prefetch is disabled - I didnt check this yet.
>
From a bit of poking around today, I think that replicas do get OS
readahead when prefetch is disabled. I also think that visibility map and
FSM reads were the largest cause of replica reads when prefetch was
disabled (these don't get FPIs), and I think FSM in particular was
triggering linux readahead. Don't have anything clean enough to publish
yet though.
One thing I wonder is if its worth discussing with Linux kernel maintainers
that there is a use case for a prefetch (WILLNEED) that doesnt disable
readahead.
On the other hand, maybe if replica prefetch could read ahead far enough
then it might be able to use io_uring/read_stream itself to batch a bunch
of sequential reads? I haven't looked at any actual data yet. Maybe
that's unrealistic.
-Jeremy
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-10-26 23:39:53 | Re: Compression of bigger WAL records |
| Previous Message | Lukas Fittl | 2026-10-26 23:21:26 | Assert failure in parallel query due to SubPlan double visit for hash join |