Re: Pluggable cumulative statistics
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-07-04T20:56:52Z
Lists: pgsql-hackers
Hi, On 2024-07-03 18:47:15 +0900, Michael Paquier wrote: > While looking at a different patch from Tristan in this area at [1], I > still got annoyed that this patch set was not able to support the case > of custom fixed-numbered stats, so as it is possible to plug in > pgstats things similar to the archiver, the checkpointer, WAL, etc. > These are plugged in shared memory, and are handled with copies in the > stats snapshots. After a good night of sleep, I have come up with a > good solution for that, among the following lines: > - PgStat_ShmemControl holds an array of void* indexed by > PGSTAT_NUM_KINDS, pointing to shared memory areas allocated for each > fixed-numbered stats. Each entry is allocated a size corresponding to > PgStat_KindInfo->shared_size. I am dubious this is a good idea. The more indirection you add, the more expensive it gets to count stuff, the more likely it is that we end up with backend-local "caching" in front of the stats system. IOW, I am against making builtin stats pay the price for pluggable fixed-numbered stats. It also substantially reduces type-safety, making it harder to refactor. Note that you had to add static casts in a good number of additional places. Greetings, Andres Freund
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