| From: | Jan Nidzwetzki <jan(at)planetscale(dot)com> |
|---|---|
| To: | Tomas Vondra <tomas(at)vondra(dot)me>, shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Jeremy Schneider <schneider(at)ardentperf(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Subject: | Re: improving handling of FPIs during recovery prefetching |
| Date: | 2026-11-12 12:22:38 |
| Message-ID: | 699018c1-207f-486d-bfda-809d81843fa3@planetscale.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Tomas,
On 10.11.26 13:20, Tomas Vondra wrote:
> FYI I had a chat with Thomas Munro, who wrote the current recovery
> prefetcher, and he has some ideas for an alternative (simpler, better)
> way to make it skip FPIs.
Thanks for the update. Looking forward to seeing Thomas Munro's approach.
> FWIW one aspect of my patch worth checking would be the cost for "normal
> cases" where recovery works perfectly fine without the patch. The lookup
> in the new "history" cache might be adding measurable CPU overhead, or
> something like that. I don't think it does (and I haven't managed to
> construct such case), but if someone else verified it, that'd be good.
I also tried to construct such a case: pgbench -N at scale 1 with
frequent checkpoints (max_wal_size = 64MB). After every checkpoint, the
first change to every page writes a new FPI. However, the table is small
enough that its pages remain in shared buffers. As a result, the master
branch issues very few unnecessary prefetches (1,659 during the whole
run), so the patch provides no benefit here.
I replayed the same WAL (3 million transactions) from a base backup with
the data already in the page cache. The master branch took 2.81 seconds,
and with the patch it took 2.83 seconds (medians of 10 alternating
runs), which is within normal variation. So I did not observe any
measurable overhead either.
In another run, I added temporary counters to XLogPrefetcherHasFPI().
Out of 9.0 million block references, 5.8 million reached the check. The
quick exit from 0009 returned early for 5.3 million of those, and the
history was searched 567,000 times, which is 6.3% of all block references.
Best regards
Jan
--
Jan Nidzwetzki
PlanetScale
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-11-12 12:57:38 | Re: reconsider_full_join_clause fails to consider if COALESCE() arguments are NULL-preserving |
| Previous Message | JoongHyuk Shin | 2026-11-12 11:58:20 | Re: [PATCH] Add recovery boundary WAL record for database and tablespace commands |