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 1ovhjS-0001iA-SX for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Nov 2022 16:27:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovhjR-000259-Ob for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Nov 2022 16:27:17 +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 1ovhgv-0003s1-Pk for pgsql-hackers@lists.postgresql.org; Thu, 17 Nov 2022 16:24:42 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovhgo-0008D4-8q for pgsql-hackers@lists.postgresql.org; Thu, 17 Nov 2022 16:24:40 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E3B2A5C078F; Thu, 17 Nov 2022 11:24:32 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 17 Nov 2022 11:24:32 -0500 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=fm1; t=1668702272; x=1668788672; bh=hpxSL2ryT0 AHEyifIab+YuoXSiZ7SgJba7IwvxP6YKg=; b=j597LR8NRf+NjiHE3/fME8AfIO YUx3zYF/eR6O6nbcA/82oNeatL3ZLQAVMyePJLfyVtVwxt+jHiQOVGiKzmy512A9 lu39f4HT1XQIUEwBAqD2pbPlFR79RDRv+wdYSNlrKvEGWnzbCsbsIKJLc0SABTU2 kzGrQCKCQ4QMkYCtNbw5ZgfQ35//Qb8DIpZzAipUN7VduEeQNsDH0NWTDWEQ66lZ ICsW+cqWLzUPTkqjhOkkx3nR89aY4tF6LCa8jZZX+g5XfZ+Yq3OxQUnK7WJREuQR U0LfTaow7qM1Q+zY13crXIGyjRxNDJT2DXMD/v1LklfYZxiXRIlmtjmzSmgg== 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= fm1; t=1668702272; x=1668788672; bh=hpxSL2ryT0AHEyifIab+YuoXSiZ7 SgJba7IwvxP6YKg=; b=fTP0n6gmal3slkYH9M2HdBQrZuh6wbY+CGNSLCQCu6gY NC4tHr66vQ5EucyWrnElD5CI3ifGSynsFq605SHTem9gDSUPhqVNCs8nIPEN/Nu/ Dtv1xpzKnnhnb55ukO3pt9wUnN7RuC4ul+1B2FouhfPNL0MFpGpioY9w5flkZPvy r65RHYf/46xmdKzrlLZy7PiOn/kAywCnEsfBszi5F6I+XyXuQRwAka7mn+FNqDpZ 47DVSJ01FUGBQlLUYpMaVkk7URMWxurnVVirgOn6nH5bZnvxYoX65K7mS99V917f sFF5rnLgPglLlreXxHArFgDa4GjL5RKQISIwXGXKdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgeekgdekiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteevudei tedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 17 Nov 2022 11:24:32 -0500 (EST) Date: Thu, 17 Nov 2022 08:24:31 -0800 From: Andres Freund To: Robert Haas Cc: Melanie Plageman , Bharath Rupireddy , "Drouvot, Bertrand" , Nitin Jadhav , Matthias van de Meent , Ashutosh Sharma , Julien Rouhaud , Bruce Momjian , Tom Lane , Magnus Hagander , PostgreSQL Hackers Subject: Re: Report checkpoint progress with pg_stat_progress_checkpoint (was: Report checkpoint progress in server logs) Message-ID: <20221117162431.a3kqnpgjjsa7foxy@awork3.anarazel.de> References: <20220319001556.atuqbmafvc73pa2k@alap3.anarazel.de> <20220707000446.hefgyu5xikxwt4md@alap3.anarazel.de> <20221116195232.wynvnlng2ivne76b@awork3.anarazel.de> 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, On 2022-11-17 09:03:32 -0500, Robert Haas wrote: > On Wed, Nov 16, 2022 at 2:52 PM Andres Freund wrote: > > I don't think we'd want every buffer write or whatnot go through the > > changecount mechanism, on some non-x86 platforms that could be noticable. But > > if we didn't stage the stats updates locally I think we could make most of the > > stats changes without that overhead. For updates that just increment a single > > counter there's simply no benefit in the changecount mechanism afaict. > > You might be right, but I'm not sure whether it's worth stressing > about. The progress reporting mechanism uses the st_changecount > mechanism, too, and as far as I know nobody's complained about that > having too much overhead. Maybe they have, though, and I've just > missed it. I've seen it in profiles, although not as the major contributor. Most places do a reasonable amount of work between calls though. As an experiment, I added a progress report to BufferSync()'s first loop (i.e. where it checks all buffers). On a 128GB shared_buffers cluster that increases the time for a do-nothing checkpoint from ~235ms to ~280ms. If I remove the changecount stuff and use a single write + write barrier, it ends up as 250ms. Inlining brings it down a bit further, to 247ms. Obviously this is a very extreme case - we only do very little work between the progress report calls. But it does seem to show that the overhead is not entirely neglegible. I think pgstat_progress_start_command() needs the changecount stuff, as does pgstat_progress_update_multi_param(). But for anything updating a single parameter at a time it really doesn't do anything useful on a platform that doesn't tear 64bit writes (so it could be #ifdef PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY). Out of further curiosity I wanted to test the impact when the loop doesn't even do a LockBufHdr() and added an unlocked pre-check. 109ms without progress. 138ms with. 114ms with the simplified pgstat_progress_update_param(). 108ms after inlining the simplified pgstat_progress_update_param(). Greetings, Andres Freund