From d47d83151bf3534a7ddecbe286ca980c4601872a Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Tue, 29 Mar 2022 20:34:49 -0700
Subject: [PATCH v70 02/27] pgstat: stats collector references in comments

Author: Andres Freund <andres@anarazel.de>
Reviewed-By: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-By: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
Discussion: https://postgr.es/m/20220308205351.2xcn6k4x5yivcxyd@alap3.anarazel.de
---
 src/include/pgstat.h                          |  4 +--
 src/include/utils/backend_status.h            |  4 +--
 src/include/utils/pgstat_internal.h           |  2 +-
 src/backend/access/heap/heapam_handler.c      |  4 +--
 src/backend/access/heap/vacuumlazy.c          |  8 +++---
 src/backend/commands/analyze.c                |  2 +-
 src/backend/commands/dbcommands.c             |  2 +-
 src/backend/commands/matview.c                |  8 +++---
 src/backend/commands/subscriptioncmds.c       |  4 +--
 src/backend/commands/vacuum.c                 |  4 +--
 src/backend/postmaster/autovacuum.c           | 14 +++++-----
 src/backend/postmaster/bgwriter.c             |  4 +--
 src/backend/postmaster/checkpointer.c         | 14 +++-------
 src/backend/postmaster/pgarch.c               |  8 +++---
 src/backend/postmaster/pgstat.c               | 28 +++++++++----------
 src/backend/postmaster/walwriter.c            |  9 +++---
 src/backend/replication/basebackup.c          |  4 +--
 src/backend/tcop/postgres.c                   |  8 +++---
 src/backend/utils/activity/pgstat_archiver.c  |  3 +-
 src/backend/utils/activity/pgstat_bgwriter.c  |  2 +-
 .../utils/activity/pgstat_checkpointer.c      |  2 +-
 src/backend/utils/activity/pgstat_database.c  | 14 +++++-----
 src/backend/utils/activity/pgstat_relation.c  | 16 +++++------
 src/backend/utils/activity/pgstat_replslot.c  | 10 +++----
 src/backend/utils/activity/pgstat_slru.c      |  3 +-
 .../utils/activity/pgstat_subscription.c      |  8 +++---
 src/backend/utils/adt/pgstatfuncs.c           |  4 +--
 src/backend/utils/error/elog.c                |  2 +-
 contrib/test_decoding/t/001_repl_stats.pl     |  3 +-
 src/test/regress/expected/stats.out           |  2 +-
 src/test/regress/sql/stats.sql                |  2 +-
 31 files changed, 95 insertions(+), 107 deletions(-)

diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 3584078f6ea..7ce26f61642 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -1,7 +1,7 @@
 /* ----------
  *	pgstat.h
  *
- *	Definitions for the PostgreSQL statistics collector daemon.
+ *	Definitions for the PostgreSQL cumulative statistics system.
  *
  *	Copyright (c) 2001-2022, PostgreSQL Global Development Group
  *
@@ -86,7 +86,7 @@ typedef enum PgStat_Single_Reset_Type
  * it against zeroes to detect whether there are any counts to transmit.
  *
  * Note that the time counters are in instr_time format here.  We convert to
- * microseconds in PgStat_Counter format when transmitting to the collector.
+ * microseconds in PgStat_Counter format when flushing out pending statistics.
  * ----------
  */
 typedef struct PgStat_FunctionCounts
diff --git a/src/include/utils/backend_status.h b/src/include/utils/backend_status.h
index 8217d0cb6b7..7403bca25ed 100644
--- a/src/include/utils/backend_status.h
+++ b/src/include/utils/backend_status.h
@@ -85,8 +85,8 @@ typedef struct PgBackendGSSStatus
  *
  * Each live backend maintains a PgBackendStatus struct in shared memory
  * showing its current activity.  (The structs are allocated according to
- * BackendId, but that is not critical.)  Note that the collector process
- * has no involvement in, or even access to, these structs.
+ * BackendId, but that is not critical.)  Note that this is unrelated to the
+ * cumulative stats system (i.e. pgstat.c et al).
  *
  * Each auxiliary process also maintains a PgBackendStatus struct in shared
  * memory.
diff --git a/src/include/utils/pgstat_internal.h b/src/include/utils/pgstat_internal.h
index abbb4f8d964..b95e1f56eab 100644
--- a/src/include/utils/pgstat_internal.h
+++ b/src/include/utils/pgstat_internal.h
@@ -1,7 +1,7 @@
 /* ----------
  * pgstat_internal.h
  *
- * Definitions for the PostgreSQL activity statistics facility that should
+ * Definitions for the PostgreSQL cumulative statistics system that should
  * only be needed by files implementing statistics support (rather than ones
  * reporting / querying stats).
  *
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 3a9532cb4f7..666b6205a7b 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -1089,8 +1089,8 @@ heapam_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin,
 				 * our own.  In this case we should count and sample the row,
 				 * to accommodate users who load a table and analyze it in one
 				 * transaction.  (pgstat_report_analyze has to adjust the
-				 * numbers we send to the stats collector to make this come
-				 * out right.)
+				 * numbers we report to the cumulative stats system to make
+				 * this come out right.)
 				 */
 				if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(targtuple->t_data)))
 				{
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 9cdc8008c1e..092b739dda9 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -609,9 +609,9 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
 						&frozenxid_updated, &minmulti_updated, false);
 
 	/*
-	 * Report results to the stats collector, too.
+	 * Report results to the cumulative stats system, too.
 	 *
-	 * Deliberately avoid telling the stats collector about LP_DEAD items that
+	 * Deliberately avoid telling the stats system about LP_DEAD items that
 	 * remain in the table due to VACUUM bypassing index and heap vacuuming.
 	 * ANALYZE will consider the remaining LP_DEAD items to be dead "tuples".
 	 * It seems like a good idea to err on the side of not vacuuming again too
@@ -2228,10 +2228,10 @@ lazy_vacuum(LVRelState *vacrel)
 		 * dead_items space is not CPU cache resident.
 		 *
 		 * We don't take any special steps to remember the LP_DEAD items (such
-		 * as counting them in our final report to the stats collector) when
+		 * as counting them in our final update to the stats system) when
 		 * the optimization is applied.  Though the accounting used in
 		 * analyze.c's acquire_sample_rows() will recognize the same LP_DEAD
-		 * items as dead rows in its own stats collector report, that's okay.
+		 * items as dead rows in its own stats report, that's okay.
 		 * The discrepancy should be negligible.  If this optimization is ever
 		 * expanded to cover more cases then this may need to be reconsidered.
 		 */
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 736479295ad..305226692a4 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -680,7 +680,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
 	}
 
 	/*
-	 * Now report ANALYZE to the stats collector.  For regular tables, we do
+	 * Now report ANALYZE to the cumulative stats system.  For regular tables, we do
 	 * it only if not doing inherited stats.  For partitioned tables, we only
 	 * do it for inherited stats. (We're never called for not-inherited stats
 	 * on partitioned tables anyway.)
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index df16533901e..ce776c53cad 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -1665,7 +1665,7 @@ dropdb(const char *dbname, bool missing_ok, bool force)
 	DropDatabaseBuffers(db_id);
 
 	/*
-	 * Tell the stats collector to forget it immediately, too.
+	 * Tell the cumulative stats system to forget it immediately, too.
 	 */
 	pgstat_drop_database(db_id);
 
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 05e7b60059d..9ab248d25e0 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -338,10 +338,10 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
 		refresh_by_heap_swap(matviewOid, OIDNewHeap, relpersistence);
 
 		/*
-		 * Inform stats collector about our activity: basically, we truncated
-		 * the matview and inserted some new data.  (The concurrent code path
-		 * above doesn't need to worry about this because the inserts and
-		 * deletes it issues get counted by lower-level code.)
+		 * Inform cumulative stats system about our activity: basically, we
+		 * truncated the matview and inserted some new data.  (The concurrent
+		 * code path above doesn't need to worry about this because the inserts
+		 * and deletes it issues get counted by lower-level code.)
 		 */
 		pgstat_count_truncate(matviewRel);
 		if (!stmt->skipData)
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 85dacbe93d6..51505373ea4 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -1409,7 +1409,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
 	 * slot stays dropped even if the transaction rolls back.  So we cannot
 	 * run DROP SUBSCRIPTION inside a transaction block if dropping the
 	 * replication slot.  Also, in this case, we report a message for dropping
-	 * the subscription to the stats collector.
+	 * the subscription to the cumulative stats system.
 	 *
 	 * XXX The command name should really be something like "DROP SUBSCRIPTION
 	 * of a subscription that is associated with a replication slot", but we
@@ -1583,7 +1583,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
 	PG_END_TRY();
 
 	/*
-	 * Send a message for dropping this subscription to the stats collector.
+	 * Tell the cumulative stats system that the subscription is getting dropped.
 	 * We can safely report dropping the subscription statistics here if the
 	 * subscription is associated with a replication slot since we cannot run
 	 * DROP SUBSCRIPTION inside a transaction block.  Subscription statistics
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index fb33953e350..04dbbe5530a 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -352,8 +352,8 @@ vacuum(List *relations, VacuumParams *params,
 				 errmsg("PROCESS_TOAST required with VACUUM FULL")));
 
 	/*
-	 * Send info about dead objects to the statistics collector, unless we are
-	 * in autovacuum --- autovacuum.c does this for itself.
+	 * Send info about dead objects to the cumulative stats system, unless
+	 * we are in autovacuum --- autovacuum.c does this for itself.
 	 */
 	if ((params->options & VACOPT_VACUUM) && !IsAutoVacuumWorkerProcess())
 		pgstat_vacuum_stat();
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 681ef91b81e..c6d30fa5271 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1689,7 +1689,7 @@ AutoVacWorkerMain(int argc, char *argv[])
 		char		dbname[NAMEDATALEN];
 
 		/*
-		 * Report autovac startup to the stats collector.  We deliberately do
+		 * Report autovac startup to the cumulative stats system.  We deliberately do
 		 * this before InitPostgres, so that the last_autovac_time will get
 		 * updated even if the connection attempt fails.  This is to prevent
 		 * autovac from getting "stuck" repeatedly selecting an unopenable
@@ -1996,9 +1996,9 @@ do_autovacuum(void)
 	StartTransactionCommand();
 
 	/*
-	 * Clean up any dead statistics collector entries for this DB. We always
-	 * want to do this exactly once per DB-processing cycle, even if we find
-	 * nothing worth vacuuming in the database.
+	 * Clean up any dead statistics entries for this DB. We always want to do
+	 * this exactly once per DB-processing cycle, even if we find nothing
+	 * worth vacuuming in the database.
 	 */
 	pgstat_vacuum_stat();
 
@@ -3041,7 +3041,7 @@ recheck_relation_needs_vacanalyze(Oid relid,
  *
  * For analyze, the analysis done is that the number of tuples inserted,
  * deleted and updated since the last analyze exceeds a threshold calculated
- * in the same fashion as above.  Note that the collector actually stores
+ * in the same fashion as above.  Note that the cumulative stats system stores
  * the number of tuples (both live and dead) that there were as of the last
  * analyze.  This is asymmetric to the VACUUM case.
  *
@@ -3051,8 +3051,8 @@ recheck_relation_needs_vacanalyze(Oid relid,
  *
  * A table whose autovacuum_enabled option is false is
  * automatically skipped (unless we have to vacuum it due to freeze_max_age).
- * Thus autovacuum can be disabled for specific tables. Also, when the stats
- * collector does not have data about a table, it will be skipped.
+ * Thus autovacuum can be disabled for specific tables. Also, when the cumulative
+ * stats system does not have data about a table, it will be skipped.
  *
  * A table whose vac_base_thresh value is < 0 takes the base value from the
  * autovacuum_vacuum_threshold GUC variable.  Similarly, a vac_scale_factor
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c
index d1f5d12eff8..447596b2a8b 100644
--- a/src/backend/postmaster/bgwriter.c
+++ b/src/backend/postmaster/bgwriter.c
@@ -240,9 +240,7 @@ BackgroundWriterMain(void)
 		 */
 		can_hibernate = BgBufferSync(&wb_context);
 
-		/*
-		 * Send off activity statistics to the stats collector
-		 */
+		/* Report pending statistics to the cumulative stats system */
 		pgstat_send_bgwriter();
 
 		if (FirstCallSinceLastCheckpoint())
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index a59c3cf0201..80914aa891c 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -492,12 +492,8 @@ CheckpointerMain(void)
 		/* Check for archive_timeout and switch xlog files if necessary. */
 		CheckArchiveTimeout();
 
-		/*
-		 * Send off activity statistics to the stats collector.
-		 */
+		/* Report pending statistics to the cumulative stats system */
 		pgstat_send_checkpointer();
-
-		/* Send WAL statistics to the stats collector. */
 		pgstat_send_wal(true);
 
 		/*
@@ -570,8 +566,8 @@ HandleCheckpointerInterrupts(void)
 		 * Close down the database.
 		 *
 		 * Since ShutdownXLOG() creates restartpoint or checkpoint, and
-		 * updates the statistics, increment the checkpoint request and send
-		 * the statistics to the stats collector.
+		 * updates the statistics, increment the checkpoint request and flush
+		 * out pending statistic.
 		 */
 		PendingCheckpointerStats.m_requested_checkpoints++;
 		ShutdownXLOG(0, 0);
@@ -718,9 +714,7 @@ CheckpointWriteDelay(int flags, double progress)
 
 		CheckArchiveTimeout();
 
-		/*
-		 * Report interim activity statistics.
-		 */
+		/* Report interim statistics to the cumulative stats system */
 		pgstat_send_checkpointer();
 
 		/*
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index d916ed39a8c..adfa404f464 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -477,8 +477,8 @@ pgarch_ArchiverCopyLoop(void)
 				pgarch_archiveDone(xlog);
 
 				/*
-				 * Tell the collector about the WAL file that we successfully
-				 * archived
+				 * Tell the cumulative stats system about the WAL file that we
+				 * successfully archived
 				 */
 				pgstat_send_archiver(xlog, false);
 
@@ -487,8 +487,8 @@ pgarch_ArchiverCopyLoop(void)
 			else
 			{
 				/*
-				 * Tell the collector about the WAL file that we failed to
-				 * archive
+				 * Tell the cumulative stats system about the WAL file that we
+				 * failed to archive
 				 */
 				pgstat_send_archiver(xlog, true);
 
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index ef1cba61a6f..de981a89a5b 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -695,9 +695,9 @@ allow_immediate_pgstat_restart(void)
 /*
  * Shut down a single backend's statistics reporting at process exit.
  *
- * Flush any remaining statistics counts out to the collector.
- * Without this, operations triggered during backend exit (such as
- * temp table deletions) won't be counted.
+ * Flush out any remaining statistics counts.  Without this, operations
+ * triggered during backend exit (such as temp table deletions) won't be
+ * counted.
  */
 static void
 pgstat_shutdown_hook(int code, Datum arg)
@@ -705,10 +705,10 @@ pgstat_shutdown_hook(int code, Datum arg)
 	Assert(!pgstat_is_shutdown);
 
 	/*
-	 * If we got as far as discovering our own database ID, we can report what
-	 * we did to the collector.  Otherwise, we'd be sending an invalid
-	 * database ID, so forget it.  (This means that accesses to pg_database
-	 * during failed backend starts might never get counted.)
+	 * If we got as far as discovering our own database ID, we can flush out
+	 * what we did so far.  Otherwise, we'd be reporting an invalid database
+	 * ID, so forget it.  (This means that accesses to pg_database during
+	 * failed backend starts might never get counted.)
 	 */
 	if (OidIsValid(MyDatabaseId))
 		pgstat_report_stat(true);
@@ -1219,7 +1219,7 @@ pgstat_collect_oids(Oid catalogid, AttrNumber anum_oid)
 }
 
 /*
- * Tell the statistics collector to reset counters for our database.
+ * Reset counters for our database.
  *
  * Permission checking for this function is managed through the normal
  * GRANT system.
@@ -1238,7 +1238,7 @@ pgstat_reset_counters(void)
 }
 
 /*
- * Tell the statistics collector to reset a single counter.
+ * Reset a single counter.
  *
  * Permission checking for this function is managed through the normal
  * GRANT system.
@@ -1260,7 +1260,7 @@ pgstat_reset_single_counter(Oid objoid, PgStat_Single_Reset_Type type)
 }
 
 /*
- * Tell the statistics collector to reset cluster-wide shared counters.
+ * Reset cluster-wide shared counters.
  *
  * Permission checking for this function is managed through the normal
  * GRANT system.
@@ -1322,8 +1322,8 @@ pgstat_send_inquiry(TimestampTz clock_time, TimestampTz cutoff_time, Oid databas
 /*
  * Support function for the SQL-callable pgstat* functions. Returns
  * the collected statistics for one database or NULL. NULL doesn't mean
- * that the database doesn't exist, it is just not yet known by the
- * collector, so the caller is better off to report ZERO instead.
+ * that the database doesn't exist, just that there are no statistics, so the
+ * caller is better off to report ZERO instead.
  */
 PgStat_StatDBEntry *
 pgstat_fetch_stat_dbentry(Oid dbid)
@@ -1357,8 +1357,8 @@ pgstat_fetch_global(void)
 /*
  * Support function for the SQL-callable pgstat* functions. Returns
  * the collected statistics for one table or NULL. NULL doesn't mean
- * that the table doesn't exist, it is just not yet known by the
- * collector, so the caller is better off to report ZERO instead.
+ * that the table doesn't exist, just that there are no statistics, so the
+ * caller is better off to report ZERO instead.
  */
 PgStat_StatTabEntry *
 pgstat_fetch_stat_tabentry(Oid relid)
diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c
index 102fa2a089f..e2c7eb78d69 100644
--- a/src/backend/postmaster/walwriter.c
+++ b/src/backend/postmaster/walwriter.c
@@ -257,7 +257,7 @@ WalWriterMain(void)
 		else if (left_till_hibernate > 0)
 			left_till_hibernate--;
 
-		/* Send WAL statistics to the stats collector */
+		/* report pending statistics to the cumulative stats system */
 		pgstat_send_wal(false);
 
 		/*
@@ -295,12 +295,11 @@ HandleWalWriterInterrupts(void)
 	if (ShutdownRequestPending)
 	{
 		/*
-		 * Force to send remaining WAL statistics to the stats collector at
-		 * process exit.
+		 * Force reporting remaining WAL statistics at process exit.
 		 *
 		 * Since pgstat_send_wal is invoked with 'force' is false in main loop
-		 * to avoid overloading to the stats collector, there may exist unsent
-		 * stats counters for the WAL writer.
+		 * to avoid overloading the cumulative stats system, there may exist
+		 * unreported stats counters for the WAL writer.
 		 */
 		pgstat_send_wal(true);
 
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 6884cad2c00..db9fd0a7290 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -1507,8 +1507,8 @@ is_checksummed_file(const char *fullpath, const char *filename)
  *
  * If 'missing_ok' is true, will not throw an error if the file is not found.
  *
- * If dboid is anything other than InvalidOid then any checksum failures detected
- * will get reported to the stats collector.
+ * If dboid is anything other than InvalidOid then any checksum failures
+ * detected will get reported to the cumulative stats system.
  *
  * Returns true if the file was successfully sent, false if 'missing_ok',
  * and the file did not exist.
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index ba2fcfeb4af..260b650f15f 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2937,7 +2937,7 @@ die(SIGNAL_ARGS)
 		ProcDiePending = true;
 	}
 
-	/* for the statistics collector */
+	/* for the cumulative stats system */
 	pgStatSessionEndCause = DISCONNECT_KILLED;
 
 	/* If we're still here, waken anything waiting on the process latch */
@@ -4368,8 +4368,8 @@ PostgresMain(const char *dbname, const char *username)
 		 *
 		 * Note: this includes fflush()'ing the last of the prior output.
 		 *
-		 * This is also a good time to send collected statistics to the
-		 * collector, and to update the PS stats display.  We avoid doing
+		 * This is also a good time to flush out collected statistics to the
+		 * cumulative stats system, and to update the PS stats display.  We avoid doing
 		 * those every time through the message loop because it'd slow down
 		 * processing of batched messages, and because we don't want to report
 		 * uncommitted updates (that confuses autovacuum).  The notification
@@ -4710,7 +4710,7 @@ PostgresMain(const char *dbname, const char *username)
 				 */
 			case EOF:
 
-				/* for the statistics collector */
+				/* for the cumulative statistics system */
 				pgStatSessionEndCause = DISCONNECT_CLIENT_EOF;
 
 				/* FALLTHROUGH */
diff --git a/src/backend/utils/activity/pgstat_archiver.c b/src/backend/utils/activity/pgstat_archiver.c
index 4a37b8f6e76..c829b91b60c 100644
--- a/src/backend/utils/activity/pgstat_archiver.c
+++ b/src/backend/utils/activity/pgstat_archiver.c
@@ -22,8 +22,7 @@
 
 
 /*
- * Tell the collector about the WAL file that we successfully
- * archived or failed to archive.
+ * Report archiver statistics
  */
 void
 pgstat_send_archiver(const char *xlog, bool failed)
diff --git a/src/backend/utils/activity/pgstat_bgwriter.c b/src/backend/utils/activity/pgstat_bgwriter.c
index 0d9421666d8..7e7eae80372 100644
--- a/src/backend/utils/activity/pgstat_bgwriter.c
+++ b/src/backend/utils/activity/pgstat_bgwriter.c
@@ -29,7 +29,7 @@ PgStat_MsgBgWriter PendingBgWriterStats;
 
 
 /*
- * Send bgwriter statistics to the collector
+ * Report bgwriter statistics
  */
 void
 pgstat_send_bgwriter(void)
diff --git a/src/backend/utils/activity/pgstat_checkpointer.c b/src/backend/utils/activity/pgstat_checkpointer.c
index f8358eb4e0c..dbb9d861a4b 100644
--- a/src/backend/utils/activity/pgstat_checkpointer.c
+++ b/src/backend/utils/activity/pgstat_checkpointer.c
@@ -29,7 +29,7 @@ PgStat_MsgCheckpointer PendingCheckpointerStats;
 
 
 /*
- * Send checkpointer statistics to the collector
+ * Report checkpointer statistics
  */
 void
 pgstat_send_checkpointer(void)
diff --git a/src/backend/utils/activity/pgstat_database.c b/src/backend/utils/activity/pgstat_database.c
index b4fba80835a..0f2dd956d36 100644
--- a/src/backend/utils/activity/pgstat_database.c
+++ b/src/backend/utils/activity/pgstat_database.c
@@ -55,7 +55,7 @@ pgstat_drop_database(Oid databaseid)
 }
 
 /*
- * Tell the collector about a Hot Standby recovery conflict.
+ * Report a Hot Standby recovery conflict.
  */
 void
 pgstat_report_recovery_conflict(int reason)
@@ -72,7 +72,7 @@ pgstat_report_recovery_conflict(int reason)
 }
 
 /*
- * Tell the collector about a deadlock detected.
+ * Report a detected deadlock.
  */
 void
 pgstat_report_deadlock(void)
@@ -88,7 +88,7 @@ pgstat_report_deadlock(void)
 }
 
 /*
- * Tell the collector about one or more checksum failures.
+ * Report one or more checksum failures.
  */
 void
 pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
@@ -107,7 +107,7 @@ pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
 }
 
 /*
- * Tell the collector about a checksum failure.
+ * Report one checksum failure in the current database.
  */
 void
 pgstat_report_checksum_failure(void)
@@ -116,7 +116,7 @@ pgstat_report_checksum_failure(void)
 }
 
 /*
- * Tell the collector about a temporary file.
+ * Report creation of temporary file.
  */
 void
 pgstat_report_tempfile(size_t filesize)
@@ -133,7 +133,7 @@ pgstat_report_tempfile(size_t filesize)
 }
 
 /*
- * Tell the collector about a new connection.
+ * Notify stats system of a new connection.
  */
 void
 pgstat_report_connect(Oid dboid)
@@ -151,7 +151,7 @@ pgstat_report_connect(Oid dboid)
 }
 
 /*
- * Tell the collector about a disconnect.
+ * Notify the stats system of a disconnect.
  */
 void
 pgstat_report_disconnect(Oid dboid)
diff --git a/src/backend/utils/activity/pgstat_relation.c b/src/backend/utils/activity/pgstat_relation.c
index 74b62c39c0d..6413b3cc132 100644
--- a/src/backend/utils/activity/pgstat_relation.c
+++ b/src/backend/utils/activity/pgstat_relation.c
@@ -188,7 +188,7 @@ pgstat_report_autovac(Oid dboid)
 }
 
 /*
- * Tell the collector about the table we just vacuumed.
+ * Report that the table was just vacuumed.
  */
 void
 pgstat_report_vacuum(Oid tableoid, bool shared,
@@ -210,7 +210,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared,
 }
 
 /*
- * Tell the collector about the table we just analyzed.
+ * Report that the table was just analyzed.
  *
  * Caller must provide new live- and dead-tuples estimates, as well as a
  * flag indicating whether to reset the changes_since_analyze counter.
@@ -230,10 +230,10 @@ pgstat_report_analyze(Relation rel,
 	 * already inserted and/or deleted rows in the target table. ANALYZE will
 	 * have counted such rows as live or dead respectively. Because we will
 	 * report our counts of such rows at transaction end, we should subtract
-	 * off these counts from what we send to the collector now, else they'll
-	 * be double-counted after commit.  (This approach also ensures that the
-	 * collector ends up with the right numbers if we abort instead of
-	 * committing.)
+	 * off these counts from what is already written to shared stats now, else
+	 * they'll be double-counted after commit.  (This approach also ensures
+	 * that the shared stats ends up with the right numbers if we abort
+	 * instead of committing.)
 	 *
 	 * Waste no time on partitioned tables, though.
 	 */
@@ -557,8 +557,8 @@ AtPrepare_PgStat_Relations(PgStat_SubXactStatus *xact_state)
 /*
  * All we need do here is unlink the transaction stats state from the
  * nontransactional state.  The nontransactional action counts will be
- * reported to the stats collector immediately, while the effects on
- * live and dead tuple counts are preserved in the 2PC state file.
+ * reported to the stats system immediately, while the effects on live and
+ * dead tuple counts are preserved in the 2PC state file.
  *
  * Note: AtEOXact_PgStat_Relations is not called during PREPARE.
  */
diff --git a/src/backend/utils/activity/pgstat_replslot.c b/src/backend/utils/activity/pgstat_replslot.c
index a9405cd135e..35078ad73c8 100644
--- a/src/backend/utils/activity/pgstat_replslot.c
+++ b/src/backend/utils/activity/pgstat_replslot.c
@@ -23,8 +23,8 @@
 
 
 /*
- * Tell the statistics collector to reset a single replication slot
- * counter, or all replication slots counters (when name is null).
+ * Reset counters for a single replication slot, or all replication slots
+ * (when name is null).
  *
  * Permission checking for this function is managed through the normal
  * GRANT system.
@@ -51,7 +51,7 @@ pgstat_reset_replslot_counter(const char *name)
 }
 
 /*
- * Tell the collector about replication slot statistics.
+ * Report replication slot statistics.
  */
 void
 pgstat_report_replslot(const PgStat_StatReplSlotEntry *repSlotStat)
@@ -77,7 +77,7 @@ pgstat_report_replslot(const PgStat_StatReplSlotEntry *repSlotStat)
 }
 
 /*
- * Tell the collector about creating the replication slot.
+ * Report replication slot creation.
  */
 void
 pgstat_report_replslot_create(const char *slotname)
@@ -92,7 +92,7 @@ pgstat_report_replslot_create(const char *slotname)
 }
 
 /*
- * Tell the collector about dropping the replication slot.
+ * Report replication slot drop.
  */
 void
 pgstat_report_replslot_drop(const char *slotname)
diff --git a/src/backend/utils/activity/pgstat_slru.c b/src/backend/utils/activity/pgstat_slru.c
index 3e284900b15..6dae3a5dc66 100644
--- a/src/backend/utils/activity/pgstat_slru.c
+++ b/src/backend/utils/activity/pgstat_slru.c
@@ -33,8 +33,7 @@ static PgStat_MsgSLRU SLRUStats[SLRU_NUM_ELEMENTS];
 
 
 /*
- * Tell the statistics collector to reset a single SLRU counter, or all
- * SLRU counters (when name is null).
+ * Reset counters for a single SLRU, or all SLRUs (when name is null).
  *
  * Permission checking for this function is managed through the normal
  * GRANT system.
diff --git a/src/backend/utils/activity/pgstat_subscription.c b/src/backend/utils/activity/pgstat_subscription.c
index 70874e13f5e..2ee23d5ae2c 100644
--- a/src/backend/utils/activity/pgstat_subscription.c
+++ b/src/backend/utils/activity/pgstat_subscription.c
@@ -21,8 +21,8 @@
 
 
 /*
- * Tell the statistics collector to reset a single subscription
- * counter, or all subscription counters (when subid is InvalidOid).
+ * Reset counters for a single subscription, or all subscriptions (when subid
+ * is InvalidOid).
  *
  * Permission checking for this function is managed through the normal
  * GRANT system.
@@ -42,7 +42,7 @@ pgstat_reset_subscription_counter(Oid subid)
 }
 
 /*
- * Tell the collector about the subscription error.
+ * Report a subscription error.
  */
 void
 pgstat_report_subscription_error(Oid subid, bool is_apply_error)
@@ -56,7 +56,7 @@ pgstat_report_subscription_error(Oid subid, bool is_apply_error)
 }
 
 /*
- * Tell the collector about dropping the subscription.
+ * Report dropping the subscription.
  */
 void
 pgstat_report_subscription_drop(Oid subid)
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index ce84525d402..fd4276fbc67 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -1,7 +1,7 @@
 /*-------------------------------------------------------------------------
  *
  * pgstatfuncs.c
- *	  Functions for accessing the statistics collector data
+ *	  Functions for accessing various forms of statistics data
  *
  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
@@ -1820,7 +1820,7 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
 
 	SetSingleFuncCall(fcinfo, 0);
 
-	/* request SLRU stats from the stat collector */
+	/* request SLRU stats from the cumulative stats system */
 	stats = pgstat_fetch_slru();
 
 	for (i = 0;; i++)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 7402696986b..bd4b2c19b1c 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -647,7 +647,7 @@ errfinish(const char *filename, int lineno, const char *funcname)
 		fflush(stderr);
 
 		/*
-		 * Let the statistics collector know. Only mark the session as
+		 * Let the cumulative stats system know. Only mark the session as
 		 * terminated by fatal error if there is no other known cause.
 		 */
 		if (pgStatSessionEndCause == DISCONNECT_NORMAL)
diff --git a/contrib/test_decoding/t/001_repl_stats.pl b/contrib/test_decoding/t/001_repl_stats.pl
index fd82244a15c..eda8897703d 100644
--- a/contrib/test_decoding/t/001_repl_stats.pl
+++ b/contrib/test_decoding/t/001_repl_stats.pl
@@ -88,8 +88,7 @@ regression_slot3|t|t),
 # Test to remove one of the replication slots and adjust
 # max_replication_slots accordingly to the number of slots. This leads
 # to a mismatch between the number of slots present in the stats file and the
-# number of stats present in the shared memory, simulating the scenario for
-# drop slot message lost by the statistics collector process. We verify
+# number of stats present in the shared memory. We verify
 # replication statistics data is fine after restart.
 
 $node->stop;
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out
index 06a1d2f229b..57550d49e77 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -1,5 +1,5 @@
 --
--- Test Statistics Collector
+-- Test cumulative stats subsystem
 --
 -- Must be run after tenk2 has been created (by create_table),
 -- populated (by create_misc) and indexed (by create_index).
diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql
index ae1ec173e32..7e746dca3b7 100644
--- a/src/test/regress/sql/stats.sql
+++ b/src/test/regress/sql/stats.sql
@@ -1,5 +1,5 @@
 --
--- Test Statistics Collector
+-- Test cumulative stats subsystem
 --
 -- Must be run after tenk2 has been created (by create_table),
 -- populated (by create_misc) and indexed (by create_index).
-- 
2.35.1.677.gabf474a5dd

