Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4766438

Browse files
committed
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 07e9e28, 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 07e9e28 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
1 parent bd10ec5 commit 4766438

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/include/pgstat.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ typedef int64 PgStat_Counter;
128128
/* ----------
129129
* PgStat_FunctionCounts The actual per-function counts kept by a backend
130130
*
131-
* This struct should contain only actual event counters, because we memcmp
132-
* it against zeroes to detect whether there are any pending stats.
133-
*
134131
* Note that the time counters are in instr_time format here. We convert to
135132
* microseconds in PgStat_Counter format when flushing out pending statistics.
136133
* ----------
@@ -172,8 +169,10 @@ typedef struct PgStat_BackendSubEntry
172169
/* ----------
173170
* PgStat_TableCounts The actual per-table counts kept by a backend
174171
*
175-
* This struct should contain only actual event counters, because we memcmp
176-
* it against zeroes to detect whether there are any stats updates to apply.
172+
* This struct should contain only actual event counters, because we make use
173+
* of pg_memory_is_all_zeros() to detect whether there are any stats updates
174+
* to apply.
175+
*
177176
* It is a component of PgStat_TableStatus (within-backend state).
178177
*
179178
* Note: for a table, tuples_returned is the number of tuples successfully
@@ -282,6 +281,14 @@ typedef struct PgStat_ArchiverStats
282281
TimestampTz stat_reset_timestamp;
283282
} PgStat_ArchiverStats;
284283

284+
/* ---------
285+
* PgStat_BgWriterStats Background Writer statistics
286+
*
287+
* This struct should contain only actual event counters, because we make use
288+
* of pg_memory_is_all_zeros() to detect whether there are any stats updates
289+
* to apply.
290+
* ---------
291+
*/
285292
typedef struct PgStat_BgWriterStats
286293
{
287294
PgStat_Counter buf_written_clean;
@@ -290,6 +297,14 @@ typedef struct PgStat_BgWriterStats
290297
TimestampTz stat_reset_timestamp;
291298
} PgStat_BgWriterStats;
292299

300+
/* --------
301+
* PgStat_CheckpointerStats Checkpoint statistics
302+
*
303+
* This struct should contain only actual event counters, because we make use
304+
* of pg_memory_is_all_zeros() to detect whether there are any stats updates to
305+
* apply.
306+
* ---------
307+
*/
293308
typedef struct PgStat_CheckpointerStats
294309
{
295310
PgStat_Counter num_timed;

0 commit comments

Comments
 (0)