Re: Simplify VM counters in vacuum code

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Simplify VM counters in vacuum code
Date: 2025-06-24 13:17:14
Message-ID: CAAKRu_YzvF2Ogv70zEujtoL1hN3q6n1s=-2W9NaWutQpDJ23Rg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 24, 2025 at 4:01 AM Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> wrote:
>
> > Thank you for the patch! I could not understand the following change:
> >
> > + /* We know the page should not have been all-visible */
> > + Assert((old_vmbits & VISIBILITYMAP_VALID_BITS) == 0);
> > + (void) old_vmbits; /* Silence compiler */
> > +
> > + /* Count the newly set VM page for logging */
> > + if ((flags & VISIBILITYMAP_ALL_VISIBLE) != 0)
> > {
> > vacrel->vm_new_visible_pages++;
> > if (all_frozen)
> > vacrel->vm_new_visible_frozen_pages++;
> > }
> >
> > The flags is initialized as:
> >
> > uint8 flags = VISIBILITYMAP_ALL_VISIBLE;
> >
> > so the new if-condition is always true.

Yep, I fixed that in the v2 patch I just sent.

> I think we do not need to check visibility of the page here, as we
> already know that page was not all-visible due to LP_DEAD items. We
> can simply increment the vacrel->vm_new_visible_pages and check
> whether the page is frozen.

My idea with the assert was sort of to codify the expectation that the
page couldn't have been all-visible because of the dead items. But
perhaps that is obvious. But you are right that the if statement is
not needed. Perhaps I ought to remove the asserts as they may be more
confusing than helpful.

- Melanie

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-06-24 13:25:07 Re: pgsql: Introduce pg_shmem_allocations_numa view
Previous Message Melanie Plageman 2025-06-24 13:14:25 Re: Simplify VM counters in vacuum code