Re: Generate pgstat_count_slru*() functions for slru using macros

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Generate pgstat_count_slru*() functions for slru using macros
Date: 2025-09-01 01:53:41
Message-ID: aLT8pU7nv-x_Uy81@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-09-01 01:58:29 Re: Serverside SNI support in libpq
Previous Message Hayato Kuroda (Fujitsu) 2025-09-01 01:40:05 RE: doc patch: missing tags in protocol.sgml