Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tkzFl-008NgA-U1 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 05:37:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tkzFj-001MFd-NC for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 05:37:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tkzFi-001ME8-4h for pgsql-hackers@lists.postgresql.org; Thu, 20 Feb 2025 05:37:39 +0000 Received: from fout-a4-smtp.messagingengine.com ([103.168.172.147]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tkzFf-001qW7-0D for pgsql-hackers@lists.postgresql.org; Thu, 20 Feb 2025 05:37:37 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 07A5D1380418; Thu, 20 Feb 2025 00:37:34 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 20 Feb 2025 00:37:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1740029854; x=1740116254; bh=suZfSZ+EAl 7H+1wPuNXaoe3ZCDt1F3Er1UhmcONLTEo=; b=CEOYp0HF4LjAcrFFeZK/XlGx8Y cvpiRjlDjgwF5teG8hgB4OpUcwRKmL0Zhw2CXCOZ4whanaszaMkiD85prBeC1xGA yOqf++96tMDRICWjYE/wU6+rT/V6p7R4Ve85tdYkzb7BFfGlnniIQqspC4xxRK4L sR6re83iixMk5gzGBTUA+1EarOrIINX9AucDVaXvcWzX3swdiA9lYFk5riVJHPRd MFYeG6XxT+iirD0IpMBG8KXJ+RCRrD0tNu108AmyhLkHU58ULZEV5HDLBhxK3i2E d0rI/AQzdKSdSgOLRgCtTyF+5wJ8B+PAMLjtCV23U/nWv8xn7AmfcJXh9bKg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1740029854; x=1740116254; bh=suZfSZ+EAl7H+1wPuNXaoe3ZCDt1F3Er1Uh mcONLTEo=; b=OWqPPo4qeg0OEwBT1eCfZp5yIDxEnEyZhop1BBgMys/U54m+w6/ UCtJnR1Kc/V5fnvdAjCJ7mchjOhRlcCpXduHxyoMr3UTnyTFD0jcGTOberDtTgx3 i0lwOKXctOLnQMI9mqrpoGxlTsmfRDyoquFVS3MAKdBIKfWqQSpkc+W3by12jhvw ZvE69PjbmnZbw9PyP7Z9VndLGoj45PpBBudgVI9mG3lOLt+HxUqDXh4nhUJJavjQ Uhv0LCQuIc3MP9prVHybTEuVR9jOWioHVHMQE4XuYF3eOGIOTN5lCzsuuALp4lSV wR21G17uZne0NUs+UGZoTDjyWjbhG4QHhYg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeiieeffecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculd ejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhep ofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighi iiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeffhfekueevteei gfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtphht thhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsvghrthhrrghnuggurh houhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggt khgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 Feb 2025 00:37:31 -0500 (EST) Date: Thu, 20 Feb 2025 14:37:18 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Remove wal_[sync|write][_time] from pg_stat_wal and track_wal_io_timing Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Sir23Z8zFQ52Bse9" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Sir23Z8zFQ52Bse9 Content-Type: multipart/mixed; boundary="8OltpqDGl28ayoFt" Content-Disposition: inline --8OltpqDGl28ayoFt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 19, 2025 at 09:24:41AM +0000, Bertrand Drouvot wrote: > That's right but that would mean almost duplicating the pg_stat_wal relat= ed > stuff (because it can't be removed from the doc until the fields are gone= ). I=20 > think it's simpler to do it as proposed initially (the end result is the = same). After sleeping on it, I still saw no reason to not apply the changes =66rom 0002 in wal.sgml to describe that the stats for the writes/fsyncs are in pg_stat_io rather than pg_stat_wal for the "WAL configuration" section, so done that. The tags were a bit inconsistent, and I've managed to miss the.. cough.. s/sync_time/fsync_time/. 0001 was mixing a bit the tags , and , and I've moved that as a paragraph not under the tuning part, to make it a more general statement with its link to "WAL configuration", which is a very popular link for pg_stat_io. Attached is the rest, as of v3-0002. -- Michael --8OltpqDGl28ayoFt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0002-Remove-wal_-sync-write-_time-from-pg_stat_wal-and.patch" Content-Transfer-Encoding: quoted-printable =46rom b54bfecceff1f5eda6b6cfed0fa9874c7ffa0edd Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Thu, 20 Feb 2025 14:30:40 +0900 Subject: [PATCH v3] Remove wal_[sync|write][_time] from pg_stat_wal and track_wal_io_timing a051e71e28a added this information into pg_stat_io (with more details and granularity), so there is no need to keep it in pg_stat_wal. This also allows to remove PendingWalStats and simplifies up coming commits related to per backend WAL statistics. Once done, track_wal_io_timing becomes usele= ss so it is also removed. In passing remove the pgstat_prepare_io_time() parameter now that track_wal_io_timing is gone. --- src/include/access/xlog.h | 1 - src/include/catalog/pg_proc.dat | 6 +- src/include/pgstat.h | 30 +-------- src/backend/access/transam/xlog.c | 42 ++----------- src/backend/access/transam/xlogreader.c | 2 +- src/backend/access/transam/xlogrecovery.c | 2 +- src/backend/catalog/system_views.sql | 4 -- src/backend/storage/buffer/bufmgr.c | 10 +-- src/backend/storage/buffer/localbuf.c | 4 +- src/backend/storage/smgr/md.c | 4 +- src/backend/utils/activity/pgstat_io.c | 7 +-- src/backend/utils/activity/pgstat_wal.c | 24 +------ src/backend/utils/adt/pgstatfuncs.c | 20 +----- src/backend/utils/misc/guc_tables.c | 9 --- src/backend/utils/misc/postgresql.conf.sample | 1 - src/test/regress/expected/rules.out | 6 +- doc/src/sgml/config.sgml | 22 ------- doc/src/sgml/monitoring.sgml | 62 ------------------- src/tools/pgindent/typedefs.list | 1 - 19 files changed, 30 insertions(+), 227 deletions(-) diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4411c1468aca..bd18d95a6cf8 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -54,7 +54,6 @@ extern PGDLLIMPORT char *wal_consistency_checking_string; extern PGDLLIMPORT bool log_checkpoints; extern PGDLLIMPORT int CommitDelay; extern PGDLLIMPORT int CommitSiblings; -extern PGDLLIMPORT bool track_wal_io_timing; extern PGDLLIMPORT int wal_decode_buffer_size; =20 extern PGDLLIMPORT int CheckPointSegments; diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.= dat index 9e803d610d7b..1e1626964e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5950,9 +5950,9 @@ { oid =3D> '1136', descr =3D> 'statistics: information about WAL activity', proname =3D> 'pg_stat_get_wal', proisstrict =3D> 'f', provolatile =3D> '= s', proparallel =3D> 'r', prorettype =3D> 'record', proargtypes =3D> '', - proallargtypes =3D> '{int8,int8,numeric,int8,int8,int8,float8,float8,tim= estamptz}', - proargmodes =3D> '{o,o,o,o,o,o,o,o,o}', - proargnames =3D> '{wal_records,wal_fpi,wal_bytes,wal_buffers_full,wal_wr= ite,wal_sync,wal_write_time,wal_sync_time,stats_reset}', + proallargtypes =3D> '{int8,int8,numeric,int8,timestamptz}', + proargmodes =3D> '{o,o,o,o,o}', + proargnames =3D> '{wal_records,wal_fpi,wal_bytes,wal_buffers_full,stats_= reset}', prosrc =3D> 'pg_stat_get_wal' }, { oid =3D> '6248', descr =3D> 'statistics: information about WAL prefetchi= ng', proname =3D> 'pg_stat_get_recovery_prefetch', prorows =3D> '1', proretse= t =3D> 't', diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 53f2a8458e6f..030b101028f7 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -480,28 +480,9 @@ typedef struct PgStat_WalStats PgStat_Counter wal_fpi; uint64 wal_bytes; PgStat_Counter wal_buffers_full; - PgStat_Counter wal_write; - PgStat_Counter wal_sync; - PgStat_Counter wal_write_time; - PgStat_Counter wal_sync_time; TimestampTz stat_reset_timestamp; } PgStat_WalStats; =20 -/* - * This struct stores wal-related durations as instr_time, which makes it - * cheaper and easier to accumulate them, by not requiring type - * conversions. During stats flush instr_time will be converted into - * microseconds. - */ -typedef struct PgStat_PendingWalStats -{ - PgStat_Counter wal_write; - PgStat_Counter wal_sync; - instr_time wal_write_time; - instr_time wal_sync_time; -} PgStat_PendingWalStats; - - /* * Functions in pgstat.c */ @@ -583,7 +564,7 @@ extern bool pgstat_bktype_io_stats_valid(PgStat_BktypeI= O *backend_io, BackendType bktype); extern void pgstat_count_io_op(IOObject io_object, IOContext io_context, IOOp io_op, uint32 cnt, uint64 bytes); -extern instr_time pgstat_prepare_io_time(bool track_io_guc); +extern instr_time pgstat_prepare_io_time(void); extern void pgstat_count_io_op_time(IOObject io_object, IOContext io_conte= xt, IOOp io_op, instr_time start_time, uint32 cnt, uint64 bytes); @@ -834,13 +815,4 @@ extern PGDLLIMPORT PgStat_Counter pgStatTransactionIdl= eTime; /* updated by the traffic cop and in errfinish() */ extern PGDLLIMPORT SessionEndType pgStatSessionEndCause; =20 - -/* - * Variables in pgstat_wal.c - */ - -/* updated directly by backends and background processes */ -extern PGDLLIMPORT PgStat_PendingWalStats PendingWalStats; - - #endif /* PGSTAT_H */ diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam= /xlog.c index f9bf5ba75091..f1516664f5fa 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -134,7 +134,6 @@ int CommitSiblings =3D 5; /* # concurrent xacts neede= d to sleep */ int wal_retrieve_retry_interval =3D 5000; int max_slot_wal_keep_size_mb =3D -1; int wal_decode_buffer_size =3D 512 * 1024; -bool track_wal_io_timing =3D false; =20 #ifdef WAL_DEBUG bool XLOG_DEBUG =3D false; @@ -2436,10 +2435,9 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, boo= l flexible) errno =3D 0; =20 /* - * Measure I/O timing to write WAL data, for pg_stat_io and/or - * pg_stat_wal. + * Measure I/O timing to write WAL data, for pg_stat_io. */ - start =3D pgstat_prepare_io_time(track_io_timing || track_wal_io_timin= g); + start =3D pgstat_prepare_io_time(); =20 pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE); written =3D pg_pwrite(openLogFile, from, nleft, startoffset); @@ -2448,20 +2446,6 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, boo= l flexible) pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_WRITE, start, 1, written); =20 - /* - * Increment the I/O timing and the number of times WAL data - * were written out to disk. - */ - if (track_wal_io_timing) - { - instr_time end; - - INSTR_TIME_SET_CURRENT(end); - INSTR_TIME_ACCUM_DIFF(PendingWalStats.wal_write_time, end, start); - } - - PendingWalStats.wal_write++; - if (written <=3D 0) { char xlogfname[MAXFNAMELEN]; @@ -3264,7 +3248,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID l= ogtli, errmsg("could not create file \"%s\": %m", tmppath))); =20 /* Measure I/O timing when initializing segment */ - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 pgstat_report_wait_start(WAIT_EVENT_WAL_INIT_WRITE); save_errno =3D 0; @@ -3326,7 +3310,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID l= ogtli, } =20 /* Measure I/O timing when flushing segment */ - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 pgstat_report_wait_start(WAIT_EVENT_WAL_INIT_SYNC); if (pg_fsync(fd) !=3D 0) @@ -8718,10 +8702,9 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID= tli) return; =20 /* - * Measure I/O timing to sync the WAL file for pg_stat_io and/or - * pg_stat_wal. + * Measure I/O timing to sync the WAL file for pg_stat_io. */ - start =3D pgstat_prepare_io_time(track_io_timing || track_wal_io_timing); + start =3D pgstat_prepare_io_time(); =20 pgstat_report_wait_start(WAIT_EVENT_WAL_SYNC); switch (wal_sync_method) @@ -8767,21 +8750,8 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID= tli) =20 pgstat_report_wait_end(); =20 - /* - * Increment the I/O timing and the number of times WAL files were synced. - */ - if (track_wal_io_timing) - { - instr_time end; - - INSTR_TIME_SET_CURRENT(end); - INSTR_TIME_ACCUM_DIFF(PendingWalStats.wal_sync_time, end, start); - } - pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_FSYNC, start, 1, 0); - - PendingWalStats.wal_sync++; } =20 /* diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/t= ransam/xlogreader.c index 31bffc6f5019..995e4f7c26fd 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1557,7 +1557,7 @@ WALRead(XLogReaderState *state, =20 #ifndef FRONTEND /* Measure I/O timing when reading segment */ - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 pgstat_report_wait_start(WAIT_EVENT_WAL_READ); #endif diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access= /transam/xlogrecovery.c index f234007d3484..915cb330295c 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -3401,7 +3401,7 @@ retry: readOff =3D targetPageOff; =20 /* Measure I/O timing when reading segment */ - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 pgstat_report_wait_start(WAIT_EVENT_WAL_READ); r =3D pg_pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff); diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/sys= tem_views.sql index eff0990957eb..a4d2cfdcaf5d 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1189,10 +1189,6 @@ CREATE VIEW pg_stat_wal AS w.wal_fpi, w.wal_bytes, w.wal_buffers_full, - w.wal_write, - w.wal_sync, - w.wal_write_time, - w.wal_sync_time, w.stats_reset FROM pg_stat_get_wal() w; =20 diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buff= er/bufmgr.c index 75cfc2b6fe96..d3216ef6ba75 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -1509,7 +1509,7 @@ WaitReadBuffers(ReadBuffersOperation *operation) io_pages[io_buffers_len++] =3D BufferGetBlock(buffers[i]); } =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); smgrreadv(operation->smgr, forknum, io_first_block, io_pages, io_buffers= _len); pgstat_count_io_op_time(io_object, io_context, IOOP_READ, io_start, 1, io_buffers_len * BLCKSZ); @@ -2401,7 +2401,7 @@ ExtendBufferedRelShared(BufferManagerRelation bmr, } } =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 /* * Note: if smgrzeroextend fails, we will end up with buffers that are @@ -3858,7 +3858,7 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln, IOObj= ect io_object, */ bufToWrite =3D PageSetChecksumCopy((Page) bufBlock, buf->tag.blockNum); =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 /* * bufToWrite is either the shared buffer or a copy, as appropriate. @@ -4460,7 +4460,7 @@ FlushRelationBuffers(Relation rel) =20 PageSetChecksumInplace(localpage, bufHdr->tag.blockNum); =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 smgrwrite(srel, BufTagGetForkNum(&bufHdr->tag), @@ -5917,7 +5917,7 @@ IssuePendingWritebacks(WritebackContext *wb_context, = IOContext io_context) sort_pending_writebacks(wb_context->pending_writebacks, wb_context->nr_pending); =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 /* * Coalesce neighbouring writes, but nothing else. For that we iterate diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/bu= ffer/localbuf.c index 64931efaa756..78b65fb160ad 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -244,7 +244,7 @@ GetLocalVictimBuffer(void) =20 PageSetChecksumInplace(localpage, bufHdr->tag.blockNum); =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 /* And write... */ smgrwrite(oreln, @@ -414,7 +414,7 @@ ExtendBufferedRelLocal(BufferManagerRelation bmr, } } =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 /* actually extend relation */ smgrzeroextend(bmr.smgr, fork, first_block, extend_by, false); diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 7bf0b45e2c34..298754d1b64a 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -1381,7 +1381,7 @@ register_dirty_segment(SMgrRelation reln, ForkNumber = forknum, MdfdVec *seg) ereport(DEBUG1, (errmsg_internal("could not forward fsync request because request queu= e is full"))); =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 if (FileSync(seg->mdfd_vfd, WAIT_EVENT_DATA_FILE_SYNC) < 0) ereport(data_sync_elevel(ERROR), @@ -1786,7 +1786,7 @@ mdsyncfiletag(const FileTag *ftag, char *path) need_to_close =3D true; } =20 - io_start =3D pgstat_prepare_io_time(track_io_timing); + io_start =3D pgstat_prepare_io_time(); =20 /* Sync the file. */ result =3D FileSync(file, WAIT_EVENT_DATA_FILE_SYNC); diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/act= ivity/pgstat_io.c index 28a431084b89..e7362b52a37b 100644 --- a/src/backend/utils/activity/pgstat_io.c +++ b/src/backend/utils/activity/pgstat_io.c @@ -83,15 +83,14 @@ pgstat_count_io_op(IOObject io_object, IOContext io_con= text, IOOp io_op, } =20 /* - * Initialize the internal timing for an IO operation, depending on an - * IO timing GUC. + * Initialize the internal timing for an IO operation. */ instr_time -pgstat_prepare_io_time(bool track_io_guc) +pgstat_prepare_io_time(void) { instr_time io_start; =20 - if (track_io_guc) + if (track_io_timing) INSTR_TIME_SET_CURRENT(io_start); else { diff --git a/src/backend/utils/activity/pgstat_wal.c b/src/backend/utils/ac= tivity/pgstat_wal.c index c1ca65eb9918..4dc41a4a590e 100644 --- a/src/backend/utils/activity/pgstat_wal.c +++ b/src/backend/utils/activity/pgstat_wal.c @@ -21,8 +21,6 @@ #include "utils/pgstat_internal.h" =20 =20 -PgStat_PendingWalStats PendingWalStats =3D {0}; - /* * WAL usage counters saved from pgWalUsage at the previous call to * pgstat_report_wal(). This is used to calculate how much WAL usage @@ -118,17 +116,10 @@ pgstat_wal_flush_cb(bool nowait) =20 #define WALSTAT_ACC(fld, var_to_add) \ (stats_shmem->stats.fld +=3D var_to_add.fld) -#define WALSTAT_ACC_INSTR_TIME(fld) \ - (stats_shmem->stats.fld +=3D INSTR_TIME_GET_MICROSEC(PendingWalStats.fld)) WALSTAT_ACC(wal_records, wal_usage_diff); WALSTAT_ACC(wal_fpi, wal_usage_diff); WALSTAT_ACC(wal_bytes, wal_usage_diff); WALSTAT_ACC(wal_buffers_full, wal_usage_diff); - WALSTAT_ACC(wal_write, PendingWalStats); - WALSTAT_ACC(wal_sync, PendingWalStats); - WALSTAT_ACC_INSTR_TIME(wal_write_time); - WALSTAT_ACC_INSTR_TIME(wal_sync_time); -#undef WALSTAT_ACC_INSTR_TIME #undef WALSTAT_ACC =20 LWLockRelease(&stats_shmem->lock); @@ -138,11 +129,6 @@ pgstat_wal_flush_cb(bool nowait) */ prevWalUsage =3D pgWalUsage; =20 - /* - * Clear out the statistics buffer, so it can be re-used. - */ - MemSet(&PendingWalStats, 0, sizeof(PendingWalStats)); - return false; } =20 @@ -158,18 +144,12 @@ pgstat_wal_init_backend_cb(void) } =20 /* - * To determine whether any WAL activity has occurred since last time, not - * only the number of generated WAL records but also the numbers of WAL - * writes and syncs need to be checked. Because even transaction that - * generates no WAL records can write or sync WAL data when flushing the - * data pages. + * To determine whether WAL usage happened. */ bool pgstat_wal_have_pending_cb(void) { - return pgWalUsage.wal_records !=3D prevWalUsage.wal_records || - PendingWalStats.wal_write !=3D 0 || - PendingWalStats.wal_sync !=3D 0; + return pgWalUsage.wal_records !=3D prevWalUsage.wal_records; } =20 void diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pg= statfuncs.c index e9096a88492c..68e16e52ab6d 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -1637,7 +1637,7 @@ pg_stat_get_backend_io(PG_FUNCTION_ARGS) Datum pg_stat_get_wal(PG_FUNCTION_ARGS) { -#define PG_STAT_GET_WAL_COLS 9 +#define PG_STAT_GET_WAL_COLS 5 TupleDesc tupdesc; Datum values[PG_STAT_GET_WAL_COLS] =3D {0}; bool nulls[PG_STAT_GET_WAL_COLS] =3D {0}; @@ -1654,15 +1654,7 @@ pg_stat_get_wal(PG_FUNCTION_ARGS) NUMERICOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 4, "wal_buffers_full", INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 5, "wal_write", - INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 6, "wal_sync", - INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 7, "wal_write_time", - FLOAT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 8, "wal_sync_time", - FLOAT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 9, "stats_reset", + TupleDescInitEntry(tupdesc, (AttrNumber) 5, "stats_reset", TIMESTAMPTZOID, -1, 0); =20 BlessTupleDesc(tupdesc); @@ -1682,14 +1674,8 @@ pg_stat_get_wal(PG_FUNCTION_ARGS) Int32GetDatum(-1)); =20 values[3] =3D Int64GetDatum(wal_stats->wal_buffers_full); - values[4] =3D Int64GetDatum(wal_stats->wal_write); - values[5] =3D Int64GetDatum(wal_stats->wal_sync); =20 - /* Convert counters from microsec to millisec for display */ - values[6] =3D Float8GetDatum(((double) wal_stats->wal_write_time) / 1000.= 0); - values[7] =3D Float8GetDatum(((double) wal_stats->wal_sync_time) / 1000.0= ); - - values[8] =3D TimestampTzGetDatum(wal_stats->stat_reset_timestamp); + values[4] =3D TimestampTzGetDatum(wal_stats->stat_reset_timestamp); =20 /* Returns the record as Datum */ PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls)= )); diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/g= uc_tables.c index 3cde94a17595..e323b75379ac 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -1499,15 +1499,6 @@ struct config_bool ConfigureNamesBool[] =3D false, NULL, NULL, NULL }, - { - {"track_wal_io_timing", PGC_SUSET, STATS_CUMULATIVE, - gettext_noop("Collects timing statistics for WAL I/O activity."), - NULL - }, - &track_wal_io_timing, - false, - NULL, NULL, NULL - }, =20 { {"update_process_title", PGC_SUSET, PROCESS_TITLE, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/ut= ils/misc/postgresql.conf.sample index 415f253096c1..bd03540bceff 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -638,7 +638,6 @@ #track_counts =3D on #track_cost_delay_timing =3D off #track_io_timing =3D off -#track_wal_io_timing =3D off #track_functions =3D none # none, pl, all #stats_fetch_consistency =3D cache # cache, none, snapshot =20 diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expecte= d/rules.out index 5baba8d39ff6..62f69ac20b2e 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -2259,12 +2259,8 @@ pg_stat_wal| SELECT wal_records, wal_fpi, wal_bytes, wal_buffers_full, - wal_write, - wal_sync, - wal_write_time, - wal_sync_time, stats_reset - FROM pg_stat_get_wal() w(wal_records, wal_fpi, wal_bytes, wal_buffers_f= ull, wal_write, wal_sync, wal_write_time, wal_sync_time, stats_reset); + FROM pg_stat_get_wal() w(wal_records, wal_fpi, wal_bytes, wal_buffers_f= ull, stats_reset); pg_stat_wal_receiver| SELECT pid, status, receive_start_lsn, diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 9eedcf6f0f41..6d7b15d9f1e4 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -8367,28 +8367,6 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' W= ITH csv; =20 - - track_wal_io_timing (boolean) - - track_wal_io_timing configuration param= eter - - - - - Enables timing of WAL I/O calls. This parameter is off by default, - as it will repeatedly query the operating system for the current t= ime, - which may cause significant overhead on some platforms. - You can use the pg_test_timing tool to - measure the overhead of timing on your system. - I/O timing information is - displayed in - pg_stat_wal. - Only superusers and users with the appropriate SET - privilege can change this setting. - - - - track_functions (enum) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 71c4f96d0544..b8b6311f1467 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -183,11 +183,6 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss = 11:34 0:00 postgres: ser of block read, write, extend, and fsync times. =20 - - The parameter enables monit= oring - of WAL write and fsync times. - - Normally these parameters are set in postgresql.conf so that they apply to all server processes, but it is possible to turn @@ -3265,63 +3260,6 @@ description | Waiting for a newly initialized WAL fi= le to reach durable storage =20 - - - wal_write bigint - - - Number of times WAL buffers were written out to disk via - XLogWrite request. - See for more information about - the internal WAL function XLogWrite. - - - - - - wal_sync bigint - - - Number of times WAL files were synced to disk via - issue_xlog_fsync request - (if is on and - is either - fdatasync, fsync or - fsync_writethrough, otherwise zero). - See for more information about - the internal WAL function issue_xlog_fsync. - - - - - - wal_write_time double precision - - - Total amount of time spent writing WAL buffers to disk via - XLogWrite request, in milliseconds - (if is enabled, - otherwise zero). This includes the sync time when - wal_sync_method is either - open_datasync or open_sync. - - - - - - wal_sync_time double precision - - - Total amount of time spent syncing WAL files to disk via - issue_xlog_fsync request, in milliseconds - (if track_wal_io_timing is enabled, - fsync is on, and - wal_sync_method is either - fdatasync, fsync or - fsync_writethrough, otherwise zero). - - - stats_reset timestamp with time zo= ne diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs= =2Elist index fb39c915d76a..f87f304d6fc2 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -2165,7 +2165,6 @@ PgStat_KindInfo PgStat_LocalState PgStat_PendingDroppedStatsItem PgStat_PendingIO -PgStat_PendingWalStats PgStat_SLRUStats PgStat_ShmemControl PgStat_Snapshot --=20 2.47.2 --8OltpqDGl28ayoFt-- --Sir23Z8zFQ52Bse9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAme2v44ACgkQnvQgOdby QH14oBAAii2fUFyYqBzDrOF8kQbQwIslaFv5eEygve1Qt/A4HyrDhG7Losx+nI21 YXgJexS+dzOC9dYi8GymuBDNZQNP4n1NRJGwXl4PID/NfTbjF6PYzMi4z0J1Vnb+ iiB3AgBsuK6ebB3N/qgS5zygzSuF5VsY7a9ahXImM8yrxs0u09XXbD5snKD0myRT T7N/Y147joM4CePJia6S5oICwm6R9+YlYpBjiVG7bqpeEiae6XNiRLX4GRBlsuQB VGgmHweX4ogIXSTB33dctkxMwR7DipQJQeom9Alw8YojtRmFoC3Lm5MvQWDlYdQQ C/6AkHouKJ+v4jg4b+4pD7Mgl0+rM4swKwNSdX68PH3bp3Y63cVjZGXlMvODk76y szYHlYnl6w99GblWtDd5xjkFirujvxfIZYvKEoxunFgyO3Vc6y9d1FqACRhtQbWJ c3nArUEhpzbH4XIHDTxN9YbRcyaPmSrv1i1iSOyNgA7kz9PhJKh2bg2W62jNEOMF gS9eXdxw09L2Di9/d0A+jeDKjornqXSDjQ2QTbUY/uRK3Fw/MFb5Juqh6VpaTOth qbR23TwU15Ka1p5IP/eZFh0+R8nwfxcFfD/TCwHhMApNzaLKXprs4Dw4zyky295f gnJQIDERQwU3Wa4ECkm+v8iURhEhOAqFLBPs+HzkRXrKS+MMBdU= =mPIc -----END PGP SIGNATURE----- --Sir23Z8zFQ52Bse9--