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 1vQpKb-00161C-0R for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 16:03:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQpKZ-00EOkU-2c for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 16:03:52 +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 1vQpKZ-00EOkM-1f for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 16:03:51 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQpKX-002weo-2X for pgsql-hackers@postgresql.org; Wed, 03 Dec 2025 16:03:51 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id DDABD1D0006B; Wed, 3 Dec 2025 11:03:46 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Wed, 03 Dec 2025 11:03:47 -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=1764777826; x=1764864226; bh=L9WG7pXKE/ PQaS+kn7XdrnQORk9Bhy47UHqWR5iulKk=; b=c1pNko5/KHZzSjmoumO724YAK+ ehvDdqihJFNROVk5Ua+ljBC0qGSE1lSDXrtQrJw6NwUQWU86bNa4Oxlm0S8gf+WW wKtjRKKTwF6qqxcnAyv/FGCjmFSIG8zOShIOrjhiw1cyCzxNLAd277O/78EVUTY+ px+M6jUqIptnPd+LGTDCXfV18iw7wa6X1kGA1oxNX3Lqhi3Ieenl5wU5jVdetkX+ jYVpbxJWgOYR1kZZkTn5DjGJMSwdVLmDKT0JgZZAEAxHiBUQ0fCDodGCn9DKYFl9 +XbmaCzrCXd5nAyKR0AR2EHKg1APpJRbCBr9gaa0KW9GVZa19ZhDGmwFhatw== 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= 1764777826; x=1764864226; bh=L9WG7pXKE/PQaS+kn7XdrnQORk9Bhy47UHq WR5iulKk=; b=dgXf/zVsQZ11KJHLgmgcPCF/O4PSkLwU0kv5yGdqZs3AATR60hk tAemWLQDP3XuJ0FitiuNGZyWfe8F4KMKXTqZm8Aev8WLj8FR8DtsZ1bcfaTHyBx2 v/OZGiKbsw23txmWMO4DXVtFE2hZXcno/0o2BwpWfi7O/NS9lZJs04mMXCB1tcaX ZSwi76pNqvCg6f809FD8Ovl+bcaYXx1EIaRu4QXxgk64iUVxvOmRfM4GElqYkp7Y TJEo/uUhrUnf6KkhH2ufbd4ssr8pGgV72eo2sEsqYdZtfGDZJBk+hgU0vpxCfcxE WIWkRdt3LfBDE/Oscuy+zWQ8AHKyHf2qMUA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghsucfh rhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrthhtvg hrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefhueeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnug hrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeekpdhmohguvgepshhm thhpohhuthdprhgtphhtthhopegsohgvkhgvfihurhhmodhpohhsthhgrhgvshesghhmrg hilhdrtghomhdprhgtphhtthhopehmvghlrghnihgvphhlrghgvghmrghnsehgmhgrihhl rdgtohhmpdhrtghpthhtohepmhhitghhrggvlhdrphgrqhhuihgvrhesghhmrghilhdrtg homhdprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghp thhtohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohephh hlihhnnhgrkhgrsehikhhirdhfihdprhgtphhtthhopehnohgrhheslhgvrggusghorght rdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqh hlrdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 Dec 2025 11:03:46 -0500 (EST) Date: Wed, 3 Dec 2025 11:03:40 -0500 From: Andres Freund To: Melanie Plageman Cc: Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Heikki Linnakangas , Noah Misch , Robert Haas , Michael Paquier Subject: Re: Buffer locking is special (hints, checksums, AIO writes) Message-ID: References: <6kmid26do57ykqfpvq6iieniy4djsymhrypkjccazq5g4bbe6a@2y6owwv7qpex> <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-02 19:47:35 -0500, 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) > > - Tried to address Melanie's feedback, with some exceptions (some noted below, > but I also need to make another pass through the reviews) > > - re-implemented AssertNotCatalogBufferLock() in the new world > > - Substantially expanded comments around setting hint bits (in buffer/README, > heapam_visibility.c and bufmgr.c) > > - split out the change to fsm_vacuum_page() to start to lock the page into is > own commit > > - reordered patch series so that smaller changes are before the 64bit-state > and "Implement buffer content locks independently of" commits, so they can > be committed while we finish cleaning the later changes > > - I didn't invest much in cleaning up the later patches ("Don't copy pages > while writing out" and "Make UnlockReleaseBuffer() more efficient") yet, > wanted to focus on the earlier patches first > > > Todo: > > - still need to rename ResOwnerReleaseBufferPin(). Wondering about what to > rename ResourceOwnerDesc.name to. "buffer ownership" maybe? Not great... > > - gistkillitems() complaint by Melanie > > - amortize vs batch vs SetHintBits comment + SHB_* names > > - for the next version I'll remove the BATCHMVCC_FEWER_ARGS conditionals from > 0010. I don't love needing BatchMVCCState but I don't really see an > alternative, the performance difference is pretty persistent. > > > Questions: > - ForEachLWLockHeldByMe() and LWLockDisown() aren't used anymore, should we > remove them? I'm planning to work on committing 0001, 0002, 0003, 0008 soon-ish, unless somebody sees a reason to hold off on that. After that I think 0005, 0006 would be next. I think 0004 is a clear improvement, but nobody has looked at it yet... For 0007, I wished ConditionalLockBuffer() accepted the lock level, there's no point in waiting for the lock in the use case. I'm on the fence about whether it's worth changing the ~12 users of ConditionalLockBuffer()... Greetings, Andres Freund