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.96) (envelope-from ) id 1w4vnB-002htf-00 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 07:03:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4vn9-004x9r-1I for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 07:03:07 +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.96) (envelope-from ) id 1w4vn8-004x9f-2Q for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 07:03:07 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w4vn5-00000000pni-3YP5 for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 07:03:06 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 825061D00239; Tue, 24 Mar 2026 03:03:01 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Tue, 24 Mar 2026 03:03:01 -0400 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=fm1; t=1774335781; x=1774422181; bh=GwwT0gdmFu AADd1qEpE6/3L+macigDNuy0y6K9Nj1ow=; b=itZqFdZcwRLcxN3TIUPevST3ST npE0ezFuub3Up7tqe32EWdNMp50w0zzifVI58+ih6C5safgpY0b/IcB2SYfKgdcW AFM8t91G90z1kSalu6lquSVFlJCgw+AlIF06SXwq2aXoRJZ3q07DvbM3qR3tEhXw fUc2TQ7DbAPwr+ChE2JCguHO88fIOPPRCtHENCOPCP1/S/3+QuHlT5cW72084p77 pnKAGMmIVqyZ6QOOOSfOb5oykRlWYs4S+Epm+sdW7pgx81LD/fvL0/CRUMvKMMns 07H/JuLZLxqmhgur23ZzGnHBmZHRnaTWK3UQZ8XQhAbxiox3WL4beis58wKw== 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=fm1; t= 1774335781; x=1774422181; bh=GwwT0gdmFuAADd1qEpE6/3L+macigDNuy0y 6K9Nj1ow=; b=CbnhUKh4ijydU6/ZvgjuVMO3b+wfJFiSFzTtprkf5Yn1mFyn8jo 8U9kekgltgCf9Bbx2G1aGrWcumn5bcXotSNIAkEjGem9DsEAdv+acLKU4t9NKHgG 3WRZ3VHTAeL55DL1jDse6WAxyKNY4YiWNgBNEXzfEXUH6Q5U8r1VNVl0r0Vwckpr St7bSz5TquJonZcghVOuQhPYHLQClF56UIh9p22ua0JFErOjjlvd3MaBI+QXjTZw Qr5Mv9SvoYhlEGPSpcYh53PfBj7i7C2Heud+6R0Obp6ljIVPSyXgMYOYQXVf1mbk SVSVyr83iS4PFDhz8j4eCGrSy5ZdYZmWXEQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefvddtleefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeeg fffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsggvrh htrhgrnhguughrohhuvhhothdrphhgsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghn ughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpthhtohepphhgshhqlhesjhdquggrvh hishdrtghomhdprhgtphhtthhopehhthgrmhhfihgushesghhmrghilhdrtghomhdprhgt phhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlh drohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Mar 2026 03:02:59 -0400 (EDT) Date: Tue, 24 Mar 2026 16:02:55 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Andres Freund , Jeff Davis , Greg Sabino Mullane , pgsql-hackers@lists.postgresql.org Subject: Re: Adding locks statistics Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SRiiXhd6YS+PYxRu" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --SRiiXhd6YS+PYxRu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 21, 2026 at 02:55:33PM +0900, Michael Paquier wrote: > On Thu, Mar 19, 2026 at 12:25:41PM +0000, Bertrand Drouvot wrote: >> I did not check if there are any other files that could benefit of using >> locktag.h instead of lock.h but that's something I'll do and open a dedi= cated >> if any (once locktag.h is in the tree). >=20 > I have checked after that, and did not spot an area (except your patch > of course). And applied this part. The main patch has some churn in proc.c and lock.c, moving some code blocks while the main focus of the patch is to add the two pgstat() calls to report some data, so I have moved this part into its own commit, and applied it. One thing to not in lock.c: we will calculate the time difference of the wait even if log_lock_waits is disabled, without the lock stats part. As this GUC is enabled by default, it does not matter much in practice, I guess, and it matters even less with the main patch merged. The implementation of the main patch is close enough to pgstat_io.c that your logic is a no-brainer (timestamp protected by the first LWLock, each field incremented depending on locktags, etc.). Instead of a boolean flag tracking if some stats have been set, we could also have used an approach like the checkpointer stats with is_all_zeros on the pending data, perhaps? At the end, with two incrementation routines, I've let the code as-is. Another thing I am not completely sure is if the sleep time of the isolation tests is long enough. I have tested things with CLOBBER_CACHE_ALWAYS to make the setup more sensitive to timings but could not get it to fail. We'll know soon enough if the buildfarm complains. After a few more tweaks here and there (code, comments, some beautification), done. -- Michael --SRiiXhd6YS+PYxRu Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmnCNx8ACgkQnvQgOdby QH3Gog/8DhRo5Ghoz6FXTxOgtHCN4+aYEItA0sZQGdYnvu+Scc7/3pt9Ddl4kimp 6GFdMHHChZ/dl4fi5Zw3rxVzI5lzVNb16tf9Wh9gorTX/GKUmcJbcnxXfkJ25Vxo 1gLqRfZUCLCds2DoZPKs2RfrdW5ekcntG8UBKtT9sKOXouIZWgkzVmDtnKO7q8ne cUVoKfXVIqg6QJsq5DvQlyc60jkSVqF1omvAMzbSISyxSMd6LAY/GGUOOho1aaYg uHgm6AJx78yTi6Ysw9VTVEA75k6njHgAFM4b+C05oPntcCmcwxYqBjVL/vULNN8R mDkzzRIs+2MtRxBfN31SxAhL/OXHiiWl1JJIyabJ3uQSxxRlbZBhZ6n+qWW2gJ5I OJxdOVagkfOYJQgJMMcXw4k9A94AQXtKovLAaBfQ7FpoyyzyZu4zcZ2rR69BSTLD QeCTCRXx5+XNtvLagWockIQX40zZ2nROoAvYeTsHQckC2pWnpjSAya0UPLYmr65N df/A3uhGNsOp0FHR8JBr2SOePa935tWFGhtyGf2ygyVgwt0/Uqb/YDdYY5pXgsTH i6WHkJcj1cxq26Ec3/NjbPbKzq+phIWp6TnUVv6F8jkUy2a97CX+C41acfWdjaGh 9BYT2m7slTKOj5BAOefceScaosGByJ7H28tHLfdmWtd1jPoY320= =Uwhd -----END PGP SIGNATURE----- --SRiiXhd6YS+PYxRu--