Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFj7b-0002hx-90 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jan 2023 21:58:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFj7Z-0008HJ-BL for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jan 2023 21:58:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFj7Y-0008Gu-T1 for pgsql-hackers@lists.postgresql.org; Wed, 11 Jan 2023 21:58:57 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pFj7W-0003em-Fq for pgsql-hackers@postgresql.org; Wed, 11 Jan 2023 21:58:56 +0000 Received: by mail-qt1-x82f.google.com with SMTP id s5so10540156qtx.6 for ; Wed, 11 Jan 2023 13:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent: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=vJO6u2DXS3Us8rfcWLf5DCLOFO9vhF/9X/QHeejRcJU=; b=XXFAA8tVZPM+sIkeisJ8NrojL+hnsTHMkC+t83XebysaRG8Oqg1LapecBdNamW2VRW osynCOVhWpwNj0VMWBQOBiV/94bwgk+KLzp4p2ri0sh5pMU4MIKw4e1Ied05qg0bp9EH to2nNvF8Up2QI6dUBjkM2EowdetwFMSg/R3hr5qQ15whqxPuwOwfw7tD++m97tE1T/k/ 4N+5ECt7C56hX2LoIWEhZdIoIFT8BK9ncsg/NvQP12UM8JqIJ6TIAms2V3S7k3Y7oHpR fTf1oRJ91BbY8ec1O7IGhv+v6kNcNGye6ekZcjfUHXRrEBXW91LcgvBnTBwof2xqjJdr 0yfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent: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=vJO6u2DXS3Us8rfcWLf5DCLOFO9vhF/9X/QHeejRcJU=; b=wbNWgj2++NWMP93gbDv3Yvx8kfDWfIFE/+J0Esyuu4GpFQFF50r22Ogkj5kFkV34ES /1cRhNzxJg3UqRwYZKRCc5juSqRZYEuGrHIx2vIdDjNLao67ZkexrMGradpKKlM5MUQm w1T+AgOk05bLqA6bEj/RiS2l6PlEGvK4cD/qYun82EkirWgTjGdtgmqlFI1h/EWRJsOc WbgMGahgvK7Ov4eYSq67KW95ShXLGuMeLX6RYnPpY6v6igBEv1vZo91Symb9Q8FSy/7r 9Zh6bMggFXBy7iAErfn93qPUui2MhNJ/WcRyki8zqvdJudM45EFGUKD5vBrJACAJTGsu SZrg== X-Gm-Message-State: AFqh2kpv6N/xhdbzhJeTxFxM9VvWRTnyUuvLZHUbgYxK55SVXqDlL6QN bb4Qk+RUnE7BO+uUqhma/VsX4Q== X-Google-Smtp-Source: AMrXdXtxFJhkYBcXhMp/fOQUV/Kt+qD7XcaSX6HoBlyqsCdOuBD6DjWma7uGb3sVC3UBcx83b38aYg== X-Received: by 2002:ac8:6649:0:b0:3a9:87d6:5b86 with SMTP id j9-20020ac86649000000b003a987d65b86mr103654287qtp.6.1673474333121; Wed, 11 Jan 2023 13:58:53 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id w22-20020a05620a425600b006cbc00db595sm9753543qko.23.2023.01.11.13.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 13:58:52 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 279B8800E60; Wed, 11 Jan 2023 15:58:51 -0600 (CST) Date: Wed, 11 Jan 2023 15:58:51 -0600 From: Justin Pryzby To: Melanie Plageman Cc: Andres Freund , Lukas Fittl , Alvaro Herrera , Kyotaro Horiguchi , Magnus Hagander , pgsql-hackers@postgresql.org, Thomas Munro , Maciek Sakrejda Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) Message-ID: <20230111215850.GO9837@telsasoft.com> References: <20220825191527.ki6wggnawlrl53i6@awork3.anarazel.de> <20221228235613.ep47flalmnkqgnu7@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Subject: [PATCH v45 4/5] Add system view tracking IO ops per backend type The patch can/will fail with: CREATE TABLESPACE test_io_shared_stats_tblspc LOCATION ''; +WARNING: tablespaces created by regression test cases should have names starting with "regress_" CREATE TABLESPACE test_stats LOCATION ''; +WARNING: tablespaces created by regression test cases should have names starting with "regress_" (I already sent patches to address the omission in cirrus.yml) 1760 : errhint("Target must be \"archiver\", \"io\", \"bgwriter\", \"recovery_prefetch\", or \"wal\"."))); => Do you want to put these in order? pgstat_get_io_op_name() isn't currently being hit by tests; actually, it's completely unused. FlushRelationBuffers() isn't being hit for local buffers. > + pg_stat_iopg_stat_io > + > + One row per backend type, context, target object combination showing > + cluster-wide I/O statistics. I suggest: "One row for each combination of of .." > + The pg_stat_io and > + pg_statio_ set of views are especially useful for > + determining the effectiveness of the buffer cache. When the number of actual > + disk reads is much smaller than the number of buffer hits, then the cache is > + satisfying most read requests without invoking a kernel call. I would change this say "Postgres' own buffer cache is satisfying ..." > However, these > + statistics do not give the entire story: due to the way in which > + PostgreSQL handles disk I/O, data that is not in > + the PostgreSQL buffer cache might still reside in > + the kernel's I/O cache, and might therefore still be fetched without I suggest to refer to "the kernel's page cache" > + The pg_stat_io view will contain one row for each > + backend type, I/O context, and target I/O object combination showing > + cluster-wide I/O statistics. Combinations which do not make sense are > + omitted. "..for each combination of .." > + io_context for a type of I/O operation. For "for I/O operations" > + vacuum: I/O operations done outside of shared > + buffers incurred while vacuuming and analyzing permanent relations. s/incurred/performed/ > + bulkread: Qualifying large read I/O operations > + done outside of shared buffers, for example, a sequential scan of a > + large table. I don't think it's correct to say that it's "outside of" shared-buffers. s/Qualifying/Certain/ > + bulkwrite: Qualifying large write I/O operations > + done outside of shared buffers, such as COPY. Same > + Target object of an I/O operation. Possible values are: > + > + > + > + relation: This includes permanent relations. It says "includes permanent" but what seems to mean is that it "exclusive of temporary relations". > + > + > + > + read bigint > + > + > + Number of read operations in units of op_bytes. This looks too much like it means "bytes". Should say: "in number of blocks of size >op_bytes<" But wait - is it the number of read operations "in units of op_bytes" (which would means this already multiplied by op_bytes, and is in units of bytes). Or the "number of read operations" *of* op_bytes chunks ? Which would mean this is a "pure" number, and could be multipled by op_bytes to obtain a size in bytes. > + Number of write operations in units of op_bytes. > + Number of relation extend operations in units of > + op_bytes. same > + In io_context normal, this counts > + the number of times a block was evicted from a buffer and replaced with > + another block. In io_contexts > + bulkwrite, bulkread, and > + vacuum, this counts the number of times a block was > + evicted from shared buffers in order to add the shared buffer to a > + separate size-limited ring buffer. This never defines what "evicted" means. Does it mea that a dirty buffer was written out ? > + The number of times an existing buffer in a size-limited ring buffer > + outside of shared buffers was reused as part of an I/O operation in the > + bulkread, bulkwrite, or > + vacuum io_contexts. Maybe say "as part of a bulk I/O operation (bulkread, bulkwrite, or vacuum)." > + > + pg_stat_io can be used to inform database tuning. > + For example: > + > + > + > + A high evicted count can indicate that shared buffers > + should be increased. > + > + > + > + > + Client backends rely on the checkpointer to ensure data is persisted to > + permanent storage. Large numbers of files_synced by > + client backends could indicate a misconfiguration of > + shared buffers or of checkpointer. More information on checkpointer of *the* checkpointer > + Normally, client backends should be able to rely on auxiliary processes > + like the checkpointer and background writer to write out dirty data as *the* bg writer > + much as possible. Large numbers of writes by client backends could > + indicate a misconfiguration of shared buffers or of checkpointer. More *the* ckpointer Should this link to various docs for checkpointer/bgwriter ? Maybe the docs for ALTER/COPY/VACUUM/CREATE/etc should be updated to refer to some central description of ring buffers. Maybe something should be included to the appendix. -- Justin