aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-12-12 16:59:22 +0900
committerMichael Paquier <michael@paquier.xyz>2024-12-12 16:59:22 +0900
commit4766438aa317e85f3d762847b2b009f91f530b6f (patch)
tree688e86595178f1fccf72c96cfc7a677a484f2b6c /src
parentbd10ec529796a13670645e6acd640c6f290df020 (diff)
downloadpostgresql-4766438aa317e85f3d762847b2b009f91f530b6f.tar.gz
postgresql-4766438aa317e85f3d762847b2b009f91f530b6f.zip
Adjust some comments about structure properties in pg_stat.h
One comment of PgStat_TableCounts mentioned that its pending stats use memcmp() to check for the all-zero case if there is any activity. This is not true since 07e9e28b56, as pg_memory_is_all_zeros() is used. PgStat_FunctionCounts incorrectly documented that it relied on memcpy(). This has never been correct, and not relevant because function statistics do not have an all-zero check for pending stats. Checkpoint and bgwriter statistics have been always relying on memcmp() or pg_memory_is_all_zeros() (since 07e9e28b56 for the latter), and never mentioned the dependency on event counters for their all-zero checks. Let's document these properties, like the table statistics. Author: Bertrand Drouvot Discussion: https://postgr.es/m/Z1hNLvcPgVLPxCoc@ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'src')
-rw-r--r--src/include/pgstat.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 59c28b4aca8..ebfeef2f460 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -128,9 +128,6 @@ typedef int64 PgStat_Counter;
/* ----------
* PgStat_FunctionCounts The actual per-function counts kept by a backend
*
- * This struct should contain only actual event counters, because we memcmp
- * it against zeroes to detect whether there are any pending stats.
- *
* Note that the time counters are in instr_time format here. We convert to
* microseconds in PgStat_Counter format when flushing out pending statistics.
* ----------
@@ -172,8 +169,10 @@ typedef struct PgStat_BackendSubEntry
/* ----------
* PgStat_TableCounts The actual per-table counts kept by a backend
*
- * This struct should contain only actual event counters, because we memcmp
- * it against zeroes to detect whether there are any stats updates to apply.
+ * This struct should contain only actual event counters, because we make use
+ * of pg_memory_is_all_zeros() to detect whether there are any stats updates
+ * to apply.
+ *
* It is a component of PgStat_TableStatus (within-backend state).
*
* Note: for a table, tuples_returned is the number of tuples successfully
@@ -282,6 +281,14 @@ typedef struct PgStat_ArchiverStats
TimestampTz stat_reset_timestamp;
} PgStat_ArchiverStats;
+/* ---------
+ * PgStat_BgWriterStats Background Writer statistics
+ *
+ * This struct should contain only actual event counters, because we make use
+ * of pg_memory_is_all_zeros() to detect whether there are any stats updates
+ * to apply.
+ * ---------
+ */
typedef struct PgStat_BgWriterStats
{
PgStat_Counter buf_written_clean;
@@ -290,6 +297,14 @@ typedef struct PgStat_BgWriterStats
TimestampTz stat_reset_timestamp;
} PgStat_BgWriterStats;
+/* --------
+ * PgStat_CheckpointerStats Checkpoint statistics
+ *
+ * This struct should contain only actual event counters, because we make use
+ * of pg_memory_is_all_zeros() to detect whether there are any stats updates to
+ * apply.
+ * ---------
+ */
typedef struct PgStat_CheckpointerStats
{
PgStat_Counter num_timed;