Re: Inconsistency in reporting checkpointer stats

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Nitin Jadhav <nitinjadhavpostgres(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, vignesh C <vignesh21(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inconsistency in reporting checkpointer stats
Date: 2024-10-01 15:58:08
Message-ID: 2796a2f2-99db-43f2-9686-14a72187a32f@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2024/10/01 3:33, Fujii Masao wrote:
>
>
> On 2024/09/22 20:44, Nitin Jadhav wrote:
>>> +                                               CheckpointStats.ckpt_slru_written,
>>> +                                               (double) CheckpointStats.ckpt_slru_written * 100 / NBuffers,
>>>
>>> I don't think NBuffers represents the maximum number of SLRU buffers.
>>> We might need to calculate this based on specific GUC settings,
>>> like transaction_buffers.
>>
>> Great observation. Since the SLRU buffers written during a checkpoint
>> can include transaction_buffers, commit_timestamp_buffers,
>> subtransaction_buffers, multixact_member_buffers,
>> multixact_offset_buffers, and serializable_buffers, the total count of
>> SLRU buffers should be the sum of all these types. We might need to
>> introduce a global variable, such as total_slru_count, in the
>> globals.c file to hold this sum. The num_slots variable in the
>> SlruSharedData structure needs to be accessed from all types of SLRU
>> and stored in total_slru_count. This can then be used during logging
>> to calculate the percentage of SLRU buffers written. However, I’m
>> unsure if this effort is justified. While it makes sense for normal
>> buffers to display the percentage, the additional code required might
>> not provide significant value to users. Therefore, I have removed this
>> in the attached v6 patch.
>
> +1
>
> Thanks for updating the patch! It looks good to me.
> Barring any objections, I will commit this patch.

Before committing the patch, I revised it with the following changes:

- I added "shared" to the description of pg_stat_checkpointer.buffers_written
to clarify that it tracks shared buffers.
- In the checkpoint log message, I replaced "slru" with "SLRU" for consistency,
as uppercase is typically used for SLRU.
- I updated the commit message.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
v7-0001-Fix-inconsistent-reporting-of-checkpointer-stats.patch text/plain 10.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-10-01 16:06:19 Re: pg_verifybackup: TAR format backup verification
Previous Message Kirill Gavrilov 2024-10-01 15:46:32 Re: Truncate logs by max_log_size