Обсуждение: Generate pgstat_count_slru*() functions for slru using macros

Поиск
Список
Период
Сортировка

Generate pgstat_count_slru*() functions for slru using macros

От
Bertrand Drouvot
Дата:
Hi hackers,

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.

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.

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

Looking forward to your feedback,

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Вложения

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

От
Michael Paquier
Дата:
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

Вложения