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 1tkgK3-005vxH-N3 for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Feb 2025 09:24:51 +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 1tkgK1-006HPs-AB for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Feb 2025 09:24:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tkgK0-006HPj-RA for pgsql-hackers@lists.postgresql.org; Wed, 19 Feb 2025 09:24:49 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tkgJy-001jaX-19 for pgsql-hackers@lists.postgresql.org; Wed, 19 Feb 2025 09:24:48 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-43690d4605dso40645885e9.0 for ; Wed, 19 Feb 2025 01:24:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739957085; x=1740561885; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TNbJ7OPnHLtal9oyEvLioSfDLnb/PHB2yoS2K8yS1RY=; b=WjlxKp53IB2fcd10Li7B7+0RkeNEmQIJi8Sx3NH9J0iUuMqRektJFB/bDG0PQL34pr 26WYwyjcjOErt4/3KoINbXlS8Oub/pZNuxvFt7n/ePl3aPLmmjOtVjO3Kz/nSpNOxEzH si6Aih8Ndg/c9MS/hubOzcDAlDKgUj2UgTQw4KB+QTk08792+/yUCTzj6Z9ikfVD8QTZ u9Xfd8e10/0/XdLBic6cXBjBco6DpLzdpZkvLbH71Itk4JAFDui0u6Zr0YgSvThmxTZE /zJSsQCecMNBr2pgFJrcwgY045kYcqlBeMd1GCOR5up5gjUUltafZO9E0gtTATr26ae4 ShMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739957085; x=1740561885; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TNbJ7OPnHLtal9oyEvLioSfDLnb/PHB2yoS2K8yS1RY=; b=aq2lRKYBZck6HwxlYDIa9uCXEUfsS8Djyzdqho+Mp5w4pQE46+EyhZ7t8HV5h3pZKj Xd6eYo5OUlnmx0zOQ/jgrCTluLpVaKrHQtENpOR6v4BxSwH3rNiqh+yZntTwgpZiKLYk KQQPcZOChDvIRMqBNcPy4Jzia83y8Z7+hRdxFB1azj4VXzNRyVVd/wWHwuVmsk/Ss946 v2+H/neUUHLKzRQ6/EOONgUcOFpF6pZbsJyAAk6jRuAwEukEmyy0j71WcY2xZDkT9n2X 5NMQ9zwjLvUVv9toQTVmaRdJjP4WwulgeVynWqia7Ar8OuhgWME/5qRYNnwFSlg9maan vWzw== X-Gm-Message-State: AOJu0YzlF5IlbCl/0tClNd2TuS51rW9jVGCDohuvnI+Uc9WFRoQ/UbK9 j+eFLtC6mDd5zR1coFsjxXc52SpJdPXzGLzJGY/JjlfzsVyLFvWP X-Gm-Gg: ASbGnctOPbuc+gcHPfm2jsaJKB1ycdpYXDOayRsZnYPXNyms3CWJzZABDU88Y4bN2+/ qsrUBdEpMQNuBWZiICUSU3EnPobDBf2J+5f2fn4IH7DLIl74FXLtU1dcj5QRKpkeP29GHkNf0Wt wZN+jhCWDlW+BnZYLAo7zd+45PXMe2PcDg6V1YsUqWS5utSrfEF7hexCz9VhNn7e6n53JPQpt84 0TYqvebYdh22OnevcLzvLJJcVDdTBfa/GtFBNydUbsyJ8uy3G1+HTnkcYtDCV7OINvLwMsVjVCK NWuj7ViuXdJfyXEy6wsw4gCLPO0DUDRoBKz8CIyFwmciZDVGEei96hJFWv194aEur7f/RXEoLSb 2m/xdsUa3hChrUnC3snI72HE7nXPaUaCDBzz7Kk5ZN0QphcI= X-Google-Smtp-Source: AGHT+IH6irkOzav4DhBV8lHAfR+DXC5cCemeeS8InbRJfpX8cXf/zaYgfCblqOd+QPr9+3Mq/wynaw== X-Received: by 2002:a05:6000:e87:b0:38d:c55e:ebcf with SMTP id ffacd0b85a97d-38f34171521mr12934549f8f.52.1739957083539; Wed, 19 Feb 2025 01:24:43 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-181-182.eu-west-3.compute.amazonaws.com. [15.237.181.182]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f258b4118sm17759476f8f.18.2025.02.19.01.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2025 01:24:42 -0800 (PST) Date: Wed, 19 Feb 2025 09:24:41 +0000 From: Bertrand Drouvot To: Michael Paquier 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/mixed; boundary="jGJx/gZCINp6OCld" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --jGJx/gZCINp6OCld Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Wed, Feb 19, 2025 at 01:32:33PM +0900, Michael Paquier wrote: > These additions feel unbalanced with the existing contents, and > overlap with the follow-up paragraph about the tuning that can be > guessed from the contents of pg_stat_io because the new content refers > twice to the section "WAL Configuration". Perhaps this could be > simpler, with one sentence in the tuning part? I would propose > something like: > For the WAL object, "fsyncs" and "sync_time" track the sync activity > of WAL files via issue_xlog_fsync(). "writes" and "write_time" track > the write activity of WAL files via XLogWrite(). See linkend="wal-configuration"/> for more information. > > My point is that the "WAL configuration" section already provides all > the details that were in pg_stat_wal removed in 0002 and added in > 0001, leading to duplicated contents. Makes sense, done that way in the attached. > > - 0002: Remove wal_[sync|write][_time] from pg_stat_wal, PendingWalStats and > > track_wal_io_timing. That does not make sense to split this work in sub-patches > > so that all of this in done in 0002. > > - 0003: remove the pgstat_prepare_io_time() parameter. Now that track_wal_io_timing > > is gone there is no need for pgstat_prepare_io_time() to get a parameter. > > 0002 and 0003 can be grouped in the same commit, IMO. Idea was to "ease" the review but I'm fine to merge them. Done that way in the attached. > - When is enabled, the total > + When is enabled, the total > amounts of time XLogWrite writes and > issue_xlog_fsync syncs WAL data to disk are counted as > - wal_write_time and wal_sync_time in > - , respectively. > + write_time and sync_time in > + for the wal object, respectively. > > Okay to update these are part of 0002 that removes the fields, but > there is also an argument about updating that on its own because this > is actually the case on HEAD? (No need to post an updated patch for > this remark.) That's right but that would mean almost duplicating the pg_stat_wal related stuff (because it can't be removed from the doc until the fields are gone). I think it's simpler to do it as proposed initially (the end result is the same). Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --jGJx/gZCINp6OCld Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Add-details-in-the-pg_stat_io-doc-about-the-wal-o.patch" From 7b2492de4fbf30ab971e0e1637accee5f7f6e67b Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Tue, 18 Feb 2025 07:14:05 +0000 Subject: [PATCH v2 1/2] Add details in the pg_stat_io doc about the wal object Adding details about writes, fsyncs, write_time and sync_time when linked to the wal object. --- doc/src/sgml/monitoring.sgml | 9 +++++++++ 1 file changed, 9 insertions(+) 100.0% doc/src/sgml/ diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 928a6eb64b0..151d69cd0b3 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -2959,6 +2959,15 @@ description | Waiting for a newly initialized WAL file to reach durable storage linkend="wal-configuration"/>. + + + For the WAL object, fsyncs + and sync_time track the sync activity of WAL files via + issue_xlog_fsync(). writes and write_time + track the write activity of WAL files via XLogWrite(). + See for more information. + + -- 2.34.1 --jGJx/gZCINp6OCld Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0002-Remove-wal_-sync-write-_time-from-pg_stat_wal-and.patch" From f36afdf6630c7eb116284a5932c9b9e0b565ecba Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Tue, 18 Feb 2025 07:58:24 +0000 Subject: [PATCH v2 2/2] 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 useless so it is also removed. In passing remove the pgstat_prepare_io_time() parameter now that track_wal_io_timing is gone. --- doc/src/sgml/config.sgml | 22 ------- doc/src/sgml/monitoring.sgml | 62 ------------------- doc/src/sgml/wal.sgml | 12 ++-- 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/include/access/xlog.h | 1 - src/include/catalog/pg_proc.dat | 6 +- src/include/pgstat.h | 30 +-------- src/test/regress/expected/rules.out | 6 +- src/tools/pgindent/typedefs.list | 1 - 20 files changed, 36 insertions(+), 233 deletions(-) 41.6% doc/src/sgml/ 14.0% src/backend/access/transam/ 6.0% src/backend/storage/buffer/ 11.9% src/backend/utils/activity/ 9.0% src/backend/utils/adt/ 4.6% src/backend/ 10.6% src/include/ diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 9eedcf6f0f4..6d7b15d9f1e 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' WITH csv; - - track_wal_io_timing (boolean) - - track_wal_io_timing configuration parameter - - - - - Enables timing of WAL I/O calls. This parameter is off by default, - as it will repeatedly query the operating system for the current time, - 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 151d69cd0b3..0a0f2a56ea4 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. - - The parameter enables monitoring - 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 @@ -3264,63 +3259,6 @@ description | Waiting for a newly initialized WAL file to reach durable storage - - - 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 zone diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml index b908720adea..8a5ef49c1b5 100644 --- a/doc/src/sgml/wal.sgml +++ b/doc/src/sgml/wal.sgml @@ -810,11 +810,11 @@ There are two internal functions to write WAL data to disk: XLogWrite and issue_xlog_fsync. - When is enabled, the total + When is enabled, the total amounts of time XLogWrite writes and issue_xlog_fsync syncs WAL data to disk are counted as - wal_write_time and wal_sync_time in - , respectively. + write_time and sync_time in + for the WAL object, respectively. XLogWrite is normally called by XLogInsertRecord (when there is no space for the new record in WAL buffers), XLogFlush and the WAL writer, @@ -829,11 +829,11 @@ fsync, or fsync_writethrough, the write operation moves WAL buffers to kernel cache and issue_xlog_fsync syncs them to disk. Regardless - of the setting of track_wal_io_timing, the number + of the setting of track_io_timing, the number of times XLogWrite writes and issue_xlog_fsync syncs WAL data to disk are also - counted as wal_write and wal_sync - in pg_stat_wal, respectively. + counted as writes and fsyncs + in pg_stat_io for the WAL object, respectively. diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index f9bf5ba7509..f1516664f5f 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -134,7 +134,6 @@ int CommitSiblings = 5; /* # concurrent xacts needed to sleep */ int wal_retrieve_retry_interval = 5000; int max_slot_wal_keep_size_mb = -1; int wal_decode_buffer_size = 512 * 1024; -bool track_wal_io_timing = false; #ifdef WAL_DEBUG bool XLOG_DEBUG = false; @@ -2436,10 +2435,9 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible) errno = 0; /* - * 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 = pgstat_prepare_io_time(track_io_timing || track_wal_io_timing); + start = pgstat_prepare_io_time(); pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE); written = pg_pwrite(openLogFile, from, nleft, startoffset); @@ -2448,20 +2446,6 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible) pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_WRITE, start, 1, written); - /* - * 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 <= 0) { char xlogfname[MAXFNAMELEN]; @@ -3264,7 +3248,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli, errmsg("could not create file \"%s\": %m", tmppath))); /* Measure I/O timing when initializing segment */ - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); pgstat_report_wait_start(WAIT_EVENT_WAL_INIT_WRITE); save_errno = 0; @@ -3326,7 +3310,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli, } /* Measure I/O timing when flushing segment */ - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); pgstat_report_wait_start(WAIT_EVENT_WAL_INIT_SYNC); if (pg_fsync(fd) != 0) @@ -8718,10 +8702,9 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli) return; /* - * 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 = pgstat_prepare_io_time(track_io_timing || track_wal_io_timing); + start = pgstat_prepare_io_time(); 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) pgstat_report_wait_end(); - /* - * 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++; } /* diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 31bffc6f501..995e4f7c26f 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1557,7 +1557,7 @@ WALRead(XLogReaderState *state, #ifndef FRONTEND /* Measure I/O timing when reading segment */ - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); 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 473de6710d7..ac70b73749c 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -3401,7 +3401,7 @@ retry: readOff = targetPageOff; /* Measure I/O timing when reading segment */ - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); pgstat_report_wait_start(WAIT_EVENT_WAL_READ); r = pg_pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff); diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index eff0990957e..a4d2cfdcaf5 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; diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 75cfc2b6fe9..d3216ef6ba7 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++] = BufferGetBlock(buffers[i]); } - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = 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, } } - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); /* * Note: if smgrzeroextend fails, we will end up with buffers that are @@ -3858,7 +3858,7 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln, IOObject io_object, */ bufToWrite = PageSetChecksumCopy((Page) bufBlock, buf->tag.blockNum); - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); /* * bufToWrite is either the shared buffer or a copy, as appropriate. @@ -4460,7 +4460,7 @@ FlushRelationBuffers(Relation rel) PageSetChecksumInplace(localpage, bufHdr->tag.blockNum); - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); 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); - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); /* * Coalesce neighbouring writes, but nothing else. For that we iterate diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 64931efaa75..78b65fb160a 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -244,7 +244,7 @@ GetLocalVictimBuffer(void) PageSetChecksumInplace(localpage, bufHdr->tag.blockNum); - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); /* And write... */ smgrwrite(oreln, @@ -414,7 +414,7 @@ ExtendBufferedRelLocal(BufferManagerRelation bmr, } } - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); /* 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 7bf0b45e2c3..298754d1b64 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 queue is full"))); - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); 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 = true; } - io_start = pgstat_prepare_io_time(track_io_timing); + io_start = pgstat_prepare_io_time(); /* Sync the file. */ result = FileSync(file, WAIT_EVENT_DATA_FILE_SYNC); diff --git a/src/backend/utils/activity/pgstat_io.c b/src/backend/utils/activity/pgstat_io.c index 28a431084b8..e7362b52a37 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_context, IOOp io_op, } /* - * 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; - 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/activity/pgstat_wal.c index c1ca65eb991..4dc41a4a590 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" -PgStat_PendingWalStats PendingWalStats = {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) #define WALSTAT_ACC(fld, var_to_add) \ (stats_shmem->stats.fld += var_to_add.fld) -#define WALSTAT_ACC_INSTR_TIME(fld) \ - (stats_shmem->stats.fld += 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 LWLockRelease(&stats_shmem->lock); @@ -138,11 +129,6 @@ pgstat_wal_flush_cb(bool nowait) */ prevWalUsage = pgWalUsage; - /* - * Clear out the statistics buffer, so it can be re-used. - */ - MemSet(&PendingWalStats, 0, sizeof(PendingWalStats)); - return false; } @@ -158,18 +144,12 @@ pgstat_wal_init_backend_cb(void) } /* - * 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 != prevWalUsage.wal_records || - PendingWalStats.wal_write != 0 || - PendingWalStats.wal_sync != 0; + return pgWalUsage.wal_records != prevWalUsage.wal_records; } void diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index e9096a88492..68e16e52ab6 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] = {0}; bool nulls[PG_STAT_GET_WAL_COLS] = {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); BlessTupleDesc(tupdesc); @@ -1682,14 +1674,8 @@ pg_stat_get_wal(PG_FUNCTION_ARGS) Int32GetDatum(-1)); values[3] = Int64GetDatum(wal_stats->wal_buffers_full); - values[4] = Int64GetDatum(wal_stats->wal_write); - values[5] = Int64GetDatum(wal_stats->wal_sync); - - /* Convert counters from microsec to millisec for display */ - values[6] = Float8GetDatum(((double) wal_stats->wal_write_time) / 1000.0); - values[7] = Float8GetDatum(((double) wal_stats->wal_sync_time) / 1000.0); - values[8] = TimestampTzGetDatum(wal_stats->stat_reset_timestamp); + values[4] = TimestampTzGetDatum(wal_stats->stat_reset_timestamp); /* 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/guc_tables.c index 3cde94a1759..e323b75379a 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[] = 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 - }, { {"update_process_title", PGC_SUSET, PROCESS_TITLE, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 415f253096c..bd03540bcef 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -638,7 +638,6 @@ #track_counts = on #track_cost_delay_timing = off #track_io_timing = off -#track_wal_io_timing = off #track_functions = none # none, pl, all #stats_fetch_consistency = cache # cache, none, snapshot diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4411c1468ac..bd18d95a6cf 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; extern PGDLLIMPORT int CheckPointSegments; diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 9e803d610d7..1e1626964e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -5950,9 +5950,9 @@ { oid => '1136', descr => 'statistics: information about WAL activity', proname => 'pg_stat_get_wal', proisstrict => 'f', provolatile => 's', proparallel => 'r', prorettype => 'record', proargtypes => '', - proallargtypes => '{int8,int8,numeric,int8,int8,int8,float8,float8,timestamptz}', - proargmodes => '{o,o,o,o,o,o,o,o,o}', - proargnames => '{wal_records,wal_fpi,wal_bytes,wal_buffers_full,wal_write,wal_sync,wal_write_time,wal_sync_time,stats_reset}', + proallargtypes => '{int8,int8,numeric,int8,timestamptz}', + proargmodes => '{o,o,o,o,o}', + proargnames => '{wal_records,wal_fpi,wal_bytes,wal_buffers_full,stats_reset}', prosrc => 'pg_stat_get_wal' }, { oid => '6248', descr => 'statistics: information about WAL prefetching', proname => 'pg_stat_get_recovery_prefetch', prorows => '1', proretset => 't', diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 53f2a8458e6..030b101028f 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; -/* - * 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_BktypeIO *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_context, IOOp io_op, instr_time start_time, uint32 cnt, uint64 bytes); @@ -834,13 +815,4 @@ extern PGDLLIMPORT PgStat_Counter pgStatTransactionIdleTime; /* updated by the traffic cop and in errfinish() */ extern PGDLLIMPORT SessionEndType pgStatSessionEndCause; - -/* - * Variables in pgstat_wal.c - */ - -/* updated directly by backends and background processes */ -extern PGDLLIMPORT PgStat_PendingWalStats PendingWalStats; - - #endif /* PGSTAT_H */ diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index 5baba8d39ff..62f69ac20b2 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_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_full, stats_reset); pg_stat_wal_receiver| SELECT pid, status, receive_start_lsn, diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 64c6bf7a891..c86156d4718 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -2164,7 +2164,6 @@ PgStat_KindInfo PgStat_LocalState PgStat_PendingDroppedStatsItem PgStat_PendingIO -PgStat_PendingWalStats PgStat_SLRUStats PgStat_ShmemControl PgStat_Snapshot -- 2.34.1 --jGJx/gZCINp6OCld--