Re: Generate pgstat_count_slru*() functions for slru using macros - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Generate pgstat_count_slru*() functions for slru using macros
Date
Msg-id aLT8pU7nv-x_Uy81@paquier.xyz
Whole thread Raw
In response to Generate pgstat_count_slru*() functions for slru using macros  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
List pgsql-hackers
On Fri, Aug 29, 2025 at 03:02:23PM +0000, Bertrand Drouvot wrote:
> I was looking at pgstat_slru.c (I've in mind to provide some of those metrics
> per backend), and realized that the same code pattern is repeated 7 times.

So, the gist of the change is centralized around get_slru_entry(),
renaming the routines to match with the field names.  It's a bit
puzzling that we used different names for the fields and the routines,
with "blocks" vs "page".

> PFA a patch to $SUBJECT, removing a few lines of originally-duplicated
> code patterns. In passing, some functions have to be renamed to match their
> associated counter.

It does not hurt, so fine by me on consistency grounds.

> This is the same idea as 850f4b4, 8018ffb or 83a1a1b.

That rings a bell.  I'm OK with your proposal here, cutting some code.
Let's wait a bit to see if others have any comments.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: doc patch: missing tags in protocol.sgml
Next
From: Michael Paquier
Date:
Subject: Re: Serverside SNI support in libpq