Re: Pluggable cumulative statistics
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-07-11T07:42:22Z
Lists: pgsql-hackers
Attachments
- v6-0001-Switch-PgStat_Kind-from-enum-to-uint32.patch (text/x-diff) patch v6-0001
- v6-0002-Introduce-pluggable-APIs-for-Cumulative-Statistic.patch (text/x-diff) patch v6-0002
- v6-0003-doc-Add-section-for-Custom-Cumulative-Statistics-.patch (text/x-diff) patch v6-0003
- v6-0004-injection_points-Add-statistics-for-custom-points.patch (text/x-diff) patch v6-0004
- v6-0005-injection_points-Add-example-for-fixed-numbered-s.patch (text/x-diff) patch v6-0005
On Wed, Jul 10, 2024 at 09:00:31AM +0000, Bertrand Drouvot wrote: > On Wed, Jul 10, 2024 at 08:28:56AM +0000, Bertrand Drouvot wrote: >> v5-0001 LGTM. Thanks. I've applied this refactoring piece. > /* > * We found an existing statistics file. Read it and put all the hash > * table entries into place. > */ Indeed. Reworded that slightly and applied it as well. So we are down to the remaining parts of the patch, and this is going to need a consensus about a few things because this impacts the developer experience when implementing one's own custom stats: - Are folks OK with the point of fixing the kind IDs in time like RMGRs with a control in the wiki? Or should a more artistic approach be used like what I am mentioning at the bottom of [1]. The patch allows a range of IDs to be used, to make the access to the stats faster even if some area of memory may not be used. - The fixed-numbered custom stats kinds are stored in an array in PgStat_Snapshot and PgStat_ShmemControl, so as we have something consistent with the built-in kinds. This makes the tracking of the validity of the data in the snapshots split into parts of the structure for builtin and custom kinds. Perhaps there are better ideas than that? The built-in fixed-numbered kinds have no redirection. - The handling of both built-in and custom kinds touches some areas of pgstat.c and pgstat_shmem.c, which is the minimal I could come up with. Attached is a rebased patch set with the remaining pieces. [1]: https://www.postgresql.org/message-id/ZoshTO9K7O7Z1wrX%40paquier.xyz -- Michael
Commits
-
injection_points: Add some fixed-numbered statistics
- f68cd847fa40 18.0 landed
-
injection_points: Add some cumulative stats for injection points
- 75534436a477 18.0 landed
-
Add helper routines to retrieve data for custom fixed-numbered pgstats
- 2eff9e678d35 18.0 landed
-
Introduce pluggable APIs for Cumulative Statistics
- 7949d9594582 18.0 landed
-
Switch PgStat_Kind from an enum to a uint32 type
- 3188a4582a8c 18.0 landed
-
Improve comment of pgstat_read_statsfile()
- 72c0b24b2ddd 18.0 landed
-
Add a new 'F' entry type for fixed-numbered stats in pgstats file
- 9e4664d950c1 18.0 landed
-
Add PgStat_KindInfo.init_shmem_cb
- 21471f18e9d9 18.0 landed
-
Use pgstat_kind_infos to write fixed shared statistics
- b68b29bc8fec 18.0 landed
-
Replace hardcoded identifiers of pgstats file by #defines
- 9fd02525793f 18.0 landed