Re: Eager page freeze criteria clarification

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>, Jeff Davis <pgsql(at)j-davis(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Re: Eager page freeze criteria clarification
Date: 2024-01-02 18:47:07
Message-ID: CAAKRu_ZTDm1d9M+ENf6oXhW9nRT3J76vOL1ianiCW4+4M6hMoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 21, 2023 at 3:58 PM Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
>
> On Wed, Dec 13, 2023 at 12:24 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> > On Sat, Dec 9, 2023 at 5:12 AM Melanie Plageman
> > <melanieplageman(at)gmail(dot)com> wrote:
> > > The goal is to keep pages frozen for at least target_freeze_duration.
> > > target_freeze_duration is in seconds and pages only have a last
> > > modification LSN, so target_freeze_duration must be converted to LSNs.
> > > To accomplish this, I've added an LSNTimeline data structure, containing
> > > XLogRecPtr, TimestampTz pairs stored with decreasing precision as they
> > > age. When we need to translate the guc value to LSNs, we linearly
> > > interpolate it on this timeline. For the time being, the global
> > > LSNTimeline is in PgStat_WalStats and is only updated by vacuum. There
> > > is no reason it can't be updated with some other cadence and/or by some
> > > other process (nothing about it is inherently tied to vacuum). The
> > > cached translated value of target_freeze_duration is stored in each
> > > table's stats. This is arbitrary as it is not a table-level stat.
> > > However, it needs to be located somewhere that is accessible on
> > > update/delete. We may want to recalculate it more often than once per
> > > table vacuum, especially in case of long-running vacuums.
> >
> > This part sounds like it isn't quite baked yet. The idea of the data
> > structure seems fine, but updating it once per vacuum sounds fairly
> > unprincipled to me? Don't we want the updates to happen on a somewhat
> > regular wall clock cadence?
>
> Yes, this part was not fully baked. I actually discussed this with
> Andres at PGConf EU last week and he suggested that background writer
> update the LSNTimeline. He also suggested I propose the LSNTimeline in
> a new thread. I could add a pageinspect function returning the
> estimated time of last page modification given the page LSN (so it is
> proposed with a user).

I've rebased this over top of the revised LSNTimeline functionality
proposed separately in [1].
It is also registered for the current commitfest.

I plan to add the decay logic and benchmark it this week.

- Melanie

[1] https://www.postgresql.org/message-id/CAAKRu_Z7tR7D1=DR=xWQDefYk_nu_gxgW88X0HtxN6AsK-8_gA@mail.gmail.com

Attachment Content-Type Size
v3-0002-Add-LSNTimeline-for-converting-LSN-time.patch text/x-patch 8.7 KB
v3-0003-Add-LSNTimeline-to-PgStat_WalStats.patch text/x-patch 4.3 KB
v3-0005-visibilitymap_set-clear-return-previous-vm-bits.patch text/x-patch 6.6 KB
v3-0004-Bgwriter-maintains-global-LSNTimeline.patch text/x-patch 1.3 KB
v3-0001-Record-LSN-at-postmaster-startup.patch text/x-patch 2.4 KB
v3-0008-Count-table-modification-VM-clears.patch text/x-patch 19.1 KB
v3-0007-Add-guc-target_freeze_duration.patch text/x-patch 2.8 KB
v3-0006-Add-accumulator-to-calculate-normal-dist-online.patch text/x-patch 2.8 KB
v3-0009-Opportunistically-freeze-pages-unlikely-to-be-mod.patch text/x-patch 12.6 KB
v3-0010-Track-VM-sets-by-vacuum.patch text/x-patch 8.5 KB
v3-0012-Add-pg_visibility_map_summary_extended.patch text/x-patch 7.2 KB
v3-0011-Add-VM-set-and-unset-stats-to-pg_stat_all_tables.patch text/x-patch 11.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2024-01-02 19:20:24 Re: Minor cleanup for search path cache
Previous Message Tom Lane 2024-01-02 18:46:53 Re: Things I don't like about \du's "Attributes" column