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 1olZNz-0006Nq-Ef for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Oct 2022 17:31:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1olZNy-0000kP-52 for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Oct 2022 17:31:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olZNv-0000gC-Si for pgsql-hackers@lists.postgresql.org; Thu, 20 Oct 2022 17:31:13 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1olZNr-0002Mg-6F for pgsql-hackers@postgresql.org; Thu, 20 Oct 2022 17:31:10 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8D3EB5C004D; Thu, 20 Oct 2022 13:31:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 20 Oct 2022 13:31:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1666287064; x=1666373464; bh=EjHCZlyJ5Y vJ7f4ykQk0c9fZzmxBY4e9RU1zUa6SnPY=; b=akB308AEdRIdDIUdSOyQKP9ssv TEmYPjSmfgAb5BNmWm5GHfmxWeSMuy++u1vpkwel0jbqROh2eImfsoJNjn/spNpr +OCDSZM8HFjJG6tqVBkynzZLm+Zv5VuFNAQEVx95LJO1tqr9c9klJ6msNPOeclKH Mce2hdd77ztnntMZf1t25qV/PfQqwKKwSkVGIRzMKwhF/4kjzK3n6whP0gmRZwdA znuBscnL51vy+Gyi3XKLWtQBCy6QT7E8d0wo7atrKQMJWiC4i823Hft1vogt1HBB XPUA3iGLwCkCAGhbvVq0/gNVRlAwcBbZOPMDhdwOWUZxYJa9A5VtE6xEsLmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1666287064; x=1666373464; bh=EjHCZlyJ5YvJ7f4ykQk0c9fZzmxB Y4e9RU1zUa6SnPY=; b=ee5f7d87Ll6SXzV5BvccvMAG7vQz63W/VfPhsHe5TKWu jLeaZMuVshzel/C/7Zwsz/2Cq4a7MdliiXTCyAtvDKCBk4zrmUqAESD0K36AiOLg DidhN5aUysqcL2dqNALsSqaDAxUZ4dQVBk8gk8ELz8gqgUdyrnGju717ODpVRkoF BCmKUBgmcVIOzUJCu5qDJQfHagq+hX8Val7XGHGCD6YdqejRSaZQkAj9wx09OT8F ouoQch+Q8ar8JCtsCqpRsypRl6/V9+P45Y4YOAi9OKR1PsmtUfmemqv+qSVLxMBy 8ooLJHmAI3LEmNzfeE8bL5LgOeYp+eprk/uZDrtLEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeliedgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgu rhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtf frrghtthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteev udeitedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 Oct 2022 13:31:03 -0400 (EDT) Date: Thu, 20 Oct 2022 10:31:01 -0700 From: Andres Freund To: Melanie Plageman Cc: Maciek Sakrejda , Lukas Fittl , Justin Pryzby , Alvaro Herrera , Kyotaro Horiguchi , Magnus Hagander , Pg Hackers , Thomas Munro Subject: Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) Message-ID: <20221020173101.32d2is2ldsdym7jl@awork3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, - we shouldn't do pgstat_count_io_op() while the buffer header lock is held, if possible. I wonder if we should add a "source" output argument to StrategyGetBuffer(). Then nearly all the counting can happen in BufferAlloc(). - "repossession" is a very unintuitive name for me. If we want something like it, can't we just name it reuse_failed or such? - Wonder if the column names should be reads, writes, extends, etc instead of the current naming pattern - Is it actually correct to count evictions in StrategyGetBuffer()? What if we then decide to not use that buffer in BufferAlloc()? Yes, that'll be counted via rejected, but that still leaves the eviction count to be "misleading"? On 2022-10-19 15:26:51 -0400, Melanie Plageman wrote: > I have made some major changes in this area to make the columns more > useful. I have renamed and split "clocksweeps". It is now "evicted" and > "freelist acquired". This makes it clear when a block must be evicted > from a shared buffer must be and may help to identify misconfiguration > of shared buffers. I'm not sure freelist acquired is really that useful? If we don't add it, we should however definitely not count buffers from the freelist as evictions. > There is some nuance here that I tried to make clear in the docs. > "freelist acquired" in a shared context is straightforward. > "freelist acquired" in a strategy context is counted when a shared > buffer is added to the strategy ring (not when it is reused). Not sure what the second half here means - why would a buffer that's not from the freelist ever be counted as being from the freelist? > "freelist_acquired" is confusing for local buffers but I wanted to > distinguish between reuse/eviction of local buffers and initial > allocation. "freelist_acquired" seemed more fitting because there is a > clocksweep to find a local buffer and if it hasn't been allocated yet it > is allocated in a place similar to where shared buffers acquire a buffer > from the freelist. If I didn't count it here, I would need to make a new > column only for local buffers called "allocated" or something like that. I think you're making this too granular. We need to have more detail than today. But we don't necessarily need to catch every nuance. > I chose not to call "evicted" "sb_evicted" > because then we would need a separate "local_evicted". I could instead > make "local_evicted", "sb_evicted", and rename "reused" to > "strat_evicted". If I did that we would end up with separate columns for > every IO Context describing behavior when a buffer is initially acquired > vs when it is reused. > > It would look something like this: > > shared buffers: > initial: freelist_acquired > reused: sb_evicted > > local buffers: > initial: allocated > reused: local_evicted > > strategy buffers: > initial: sb_evicted | freelist_acquired > reused: strat_evicted > replaced: sb_evicted | freelist_acquired > > This seems not too bad at first, but if you consider that later we will > add other kinds of IO -- eg WAL IO or temporary file IO, we won't be > able to use these existing columns and will need to add even more > columns describing the exact behavior in those cases. I think it's clearly not the right direction. > I have also added the columns "repossessed" and "rejected". "rejected" > is when a bulkread rejects a strategy buffer because it is dirty and > requires flush. Seeing a lot of rejections could indicate you need to > vacuum. "repossessed" is the number of times a strategy buffer was > pinned or in use by another backend and had to be removed from the > strategy ring and replaced with a new shared buffer. This gives you some > indication that there is contention on blocks recently used by a > strategy. I don't immediately see a real use case for repossessed. Why isn't it sufficient to count it as part of rejected? Greetings, Andres Freund