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-08T05:30:23Z
Lists: pgsql-hackers
Attachments
- v4-0001-Use-pgstat_kind_infos-to-write-fixed-shared-stati.patch (text/x-diff) patch v4-0001
- v4-0002-Add-PgStat_KindInfo.init_shmem_cb.patch (text/x-diff) patch v4-0002
- v4-0003-Add-a-new-F-type-of-entry-in-pgstats-file.patch (text/x-diff) patch v4-0003
- v4-0004-Switch-PgStat_Kind-from-enum-to-uint32.patch (text/x-diff) patch v4-0004
- v4-0005-Introduce-pluggable-APIs-for-Cumulative-Statistic.patch (text/x-diff) patch v4-0005
- v4-0006-doc-Add-section-for-Custom-Cumulative-Statistics-.patch (text/x-diff) patch v4-0006
- v4-0007-injection_points-Add-statistics-for-custom-points.patch (text/x-diff) patch v4-0007
- v4-0008-injection_points-Add-example-for-fixed-numbered-s.patch (text/x-diff) patch v4-0008
On Fri, Jul 05, 2024 at 09:35:19AM +0900, Michael Paquier wrote: > On Thu, Jul 04, 2024 at 11:30:17AM +0000, Bertrand Drouvot wrote: >> On Wed, Jul 03, 2024 at 06:47:15PM +0900, Michael Paquier wrote: >>> - PgStat_Snapshot holds an array of void* also indexed by >>> PGSTAT_NUM_KINDS, pointing to the fixed stats stored in the >>> snapshots. >> >> Same, that's just a 96 bytes overhead (8 * PGSTAT_NUM_KINDS) as compared to now. > > Still Andres does not seem to like that much, well ;) Please find attached a rebased patch set labelled v4. Built-in fixed-numbered stats are still attached to the snapshot and shmem control structures, and custom fixed stats kinds are tracked in the same way as v3 with new members tracking data stored in TopMemoryContext for the snapshots and shmem for the control data. So, the custom and built-in stats kinds are separated into separate parts of the structures, including the "valid" flags for the snapshots. And this avoids any redirection when looking at the built-in fixed-numbered stats. I've tried at address all the previous comments (there could be stuff I've missed while rebasing, of course). The first three patches are refactoring pieces to make the rest more edible, while 0004~ implement the main logic with templates in modules/injection_points: - 0001 refactors pgstat_write_statsfile() so as a loop om PgStat_KindInfo is used to write the data. This is done with the addition of snapshot_ctl_off in PgStat_KindInfo, to point to the area in PgStat_Snapshot where the data is located for fixed stats. 9004abf6206e has done the same for the read part. - 0002 adds an init_shmem callback, to let stats kinds initialize states based on what's been allocated. - 0003 refactors the read/write to use a new entry type in the stats file for fixed-numbered stats. - 0004 switches PgStat_Kind from an enum to uint32, adding a better type for pluggability. - 0005 is the main implementation. - 0006 adds some docs. - 0007 (variable-numbered stats) and 0008 (fixed-numbered stats) are the examples demonstrating how to make pluggable stats for both types, with tests of their own. -- 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