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 1vVsvG-009Qdc-36 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Dec 2025 14:54:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVsvF-00DMRs-2t for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Dec 2025 14:54:38 +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 1vVsvF-00DMRk-0d for pgsql-hackers@lists.postgresql.org; Wed, 17 Dec 2025 14:54:38 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVsvC-001FFv-38 for pgsql-hackers@postgresql.org; Wed, 17 Dec 2025 14:54:37 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 0AE2CEC0196; Wed, 17 Dec 2025 09:54:33 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 17 Dec 2025 09:54:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; 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=1765983273; x=1766069673; bh=AQneZhIQLX TDdqEQeawO6pPNfeftqwB3GjfztrK9wEc=; b=Q+UtT0ZtpxGpquWjNaO3U1wiTU BjBXXTh2n3cLZMAjhhScHNpEhrQkIap3bQ8BV/STgmfz8FKeF8VUSRNTx2+c0bZX 1+JT+F7rtKw+lomWyLM8EWjTZ/NDwrIlGisTLsqrZx3DTPuQl9UjTS+030Bqn6z9 eEwEVYrNmyMDkHCm6OmuHWyCdcupwzlPfTv18a7U5bRAGGoi/WwDYGPINPT4/DTx NXeHBQ3eHN7vjT2/fbUiiS0oVBsR/vBONE8tw6HdbIJab48XZfkos9WX+yqkl5wg FQZJAr1RrdtJ9waDUYhJ+Uca25J9auaA6nabKiRlAEre44hXit0TIr5tsqdg== 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= 1765983273; x=1766069673; bh=AQneZhIQLXTDdqEQeawO6pPNfeftqwB3Gjf ztrK9wEc=; b=eCBHReEuN/xRJMn9FUdvqM4SON6EGVv+aiIW/yHdvikOkCu2G94 qEux71lCSAtGE5a8CRcMVtVxBtGcpOjgGzSV8hDpZoskMtinI5IUFfUpS2ueEGOx hfILVuelaJgd7YVQgbdvjUmBs1MjTPpxGuJuxjx+thjonMY3ZkCkAaGhnPEM+DIJ p/WjEQ1QMLDynApvoq78pp4G6YCZxPauwWWPMfDYS8kTYva+M+otz5eNo8laVHGf 8qeBJ+ZY/zp2pzHDRGbXgq/enyf1bxXDvFa3u/9X/D6ZS5mtLRX9KEkguUDROlHI 61IZUy4f5zK9WxV05QHrX9+ABVxS1SnITYQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdegvdekhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdfstddttddvnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeffffgledvffegtdevlefgtdeggffhvdekgfegteeiveejkeetudelveejhfeu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepkedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepsghovghkvgifuhhrmhdophhoshhtghhrvghssehgmh grihhlrdgtohhmpdhrtghpthhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghi lhdrtghomhdprhgtphhtthhopehmihgthhgrvghlrdhprghquhhivghrsehgmhgrihhlrd gtohhmpdhrtghpthhtoheprhhosggvrhhtmhhhrggrshesghhmrghilhdrtghomhdprhgt phhtthhopehthhhomhgrshdrmhhunhhrohesghhmrghilhdrtghomhdprhgtphhtthhope hhlhhinhhnrghkrgesihhkihdrfhhipdhrtghpthhtohepnhhorghhsehlvggruggsohgr thdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvsh hqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Dec 2025 09:54:32 -0500 (EST) Date: Wed, 17 Dec 2025 09:54:32 -0500 From: Andres Freund To: Heikki Linnakangas Cc: Melanie Plageman , Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Noah Misch , Robert Haas , Michael Paquier Subject: Re: Buffer locking is special (hints, checksums, AIO writes) Message-ID: References: <3je3ahgf7rrmmurxo6hnlhg5d3ffwfrtjwjxd6jm5srlv5iebp@vxqk5qtgmowr> <3w7v3w6a57jnssokap4k7thoekig72flnyhd4wp3yftzdd7lm7@f6lpcfen6hr7> <6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar> <3nce7i72ayzkunai6mkz24ckbxk74jodz4ua2chcdrwppxlxcd@w6x5kfkjrkru> 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 2025-12-17 11:25:50 +0200, Heikki Linnakangas wrote: > On 03/12/2025 02:47, Andres Freund wrote: > > On 2025-11-25 11:54:00 -0500, Andres Freund wrote: > > > Thanks a lot for that detailed review! A few questions and comments, before I > > > try to address the comments in the next version. > > > > Here's that new new version, with the following changes > > > > - Some more micro-optimizations, most importantly adding a commit that doesn't > > initialize the delay in LockBufHdr() unless needed. With those I don't see a > > consistent slowdown anymore (slight speedup on one workstation, slight > > slowdown on another, in an absurdly adverse workload) > > +1 > > I'm comparing the patched LockBufHdr() with LWLockWaitListLock(), which does > pretty much the same thing, and LWLockWaitListLock() already did the > initialization of the delay that way. But there are some small differences: > > - LockBufHdr() uses unlikely() in the initial attempt, LWLockWaitListLock() > does not I think we probably ought to do that in LWLockWaitListLock() too. > - LWLockWaitListLock() uses pg_atomic_read_u32() after spinning, > LockBufHdr() retries directly with pg_atomic_fetch_or_u32(). I think here LWLockWaitListLock() is likely right - but it seems like a change to LockBufHdr() that I would probably make in a separate commit? > Are there reasons for the differences, or is it just that they were > developed separately and ended up looking slightly different? I think it's just the latter... Thanks for reviewing, Andres Freund