From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Simplify VM counters in vacuum code |
Date: | 2025-06-24 04:12:14 |
Message-ID: | CAD21AoCCvcO+SkyBEmzjV6JmT-UbnQA0kgqWdbCxKkPr6zWNGA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jun 24, 2025 at 4:21 AM Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
>
> Hi,
>
> In dc6acfd910b8, I added some counters to track and log in
> autovacuum/vacuum output the number of pages newly set
> all-visible/frozen. Taking another look at the code recently, I
> realized the conditions for setting the counters could be simplified
> because of what we know to be true about the state of the heap page
> and VM at the time we are doing the counting.
>
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.
> Further explanation is in the attached patch. This code is only in 18/master.
The patch removes if statements and adds some assertions, which seems
to be a refactoring to me rather than a fix. I think we need to
consider whether it's really okay to apply it to v18.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-06-24 04:14:55 | Re: [PATCH] Add additional extended protocol commands to psql: \parse and \bindx |
Previous Message | John Naylor | 2025-06-24 03:49:41 | Re: Vacuum ERRORs out considering freezing dead tuples from before OldestXmin |