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 1vpZb5-00BLOe-2D for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 22:19:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpZb4-00CoR5-2K for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 22:19:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vpZb4-00CoQx-1M for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 22:19:10 +0000 Received: from fout-a5-smtp.messagingengine.com ([103.168.172.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vpZb2-00000001L4d-1TI0 for pgsql-hackers@postgresql.org; Mon, 09 Feb 2026 22:19:09 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 46A57EC0216; Mon, 9 Feb 2026 17:19:07 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Mon, 09 Feb 2026 17:19:07 -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=fm3; t=1770675547; x=1770761947; bh=Vu01SiF7lL F0x3Sncko1BNE6bwzNpDt3wzM1tIeXw/4=; b=RVjxTalpMCZnvClXyGFvRK7ZX/ T/O347Ak3sfACwab/2Nt2GxeH0YhwnfqUU/Wjce64AG5zqR/MjPiRKIk9Mr4RooC Q5k0SwONri3+42N7jQHqoL/XTYLnYOAbgQ41vyVJPuhLqidTAVqfMlfQWaklTWNl t2w4V/nRKIdfNQezJ48BiMfUVyqeY98FyI5J0OijzHZT9n27xNXW/g8JCd98Z2Zs 0tWaWjz0Kl6tt9uVc/Mq0jusQMt47iMUb6w1fAhc2qxBXltjKh+a28Yf3e57c+6N A6SpT37GDpu4fenpILqpRcroF3Z4GC+I13lmLu2JPWfoBk+nMhlDx+eGxclQ== 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=fm3; t= 1770675547; x=1770761947; bh=Vu01SiF7lLF0x3Sncko1BNE6bwzNpDt3wzM 1tIeXw/4=; b=pwIljnqInWQYF6zayH7Ma8nrDNbHaNVEOVomXs8//zRYmMBiq7P HVwj2ABxclGvzi36mBKj4RwWaCYs8CQXq9/fMwzrKEhmf0BxgN+d1Aj7gcMQ+7Sf jN+ac6rY+nTM4VP9rGRmVv82yQXTPlanJYj7lOGF9Uf6QPaYCHxVj282JfDMRiuG 71rdZazuvYrSKOafBfvi+kVKOf0QzWQ4COJHnV9xXNtzRvZCOMEjV21HZAvJG9tZ RRufqwXlwH9yHjicp60c+74jnQS9Aoq3hRZKeirkY25TXoQ/HOwccDqpgI/Lf4Hs LHL5ywsl5Ipg1//QFC8LHE/5Y7QO2ZulqJw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduleejleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetveduieet tddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeelpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegsohgvkhgvfihurhhmodhpohhsthhgrhgvshesgh hmrghilhdrtghomhdprhgtphhtthhopehmvghlrghnihgvphhlrghgvghmrghnsehgmhgr ihhlrdgtohhmpdhrtghpthhtohepmhhitghhrggvlhdrphgrqhhuihgvrhesghhmrghilh drtghomhdprhgtphhtthhopehrvghshhhkvghkihhrihhllhesghhmrghilhdrtghomhdp rhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghpthhtoh epthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohephhhlihhn nhgrkhgrsehikhhirdhfihdprhgtphhtthhopehnohgrhheslhgvrggusghorghtrdgtoh hmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdho rhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 Feb 2026 17:19:06 -0500 (EST) Date: Mon, 9 Feb 2026 17:19:06 -0500 From: Andres Freund To: Heikki Linnakangas Cc: Melanie Plageman , Noah Misch , Kirill Reshke , Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Robert Haas , Michael Paquier Subject: Re: Buffer locking is special (hints, checksums, AIO writes) Message-ID: References: <4csodkvvfbfloxxjlkgsnl2lgfv2mtzdl7phqzd4jxjadxm4o5@usw7feyb5bzf> <5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d> <9f7853f1-415e-475f-b8a7-3f32cafff68b@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9f7853f1-415e-475f-b8a7-3f32cafff68b@iki.fi> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-02-09 12:14:47 +0200, Heikki Linnakangas wrote: > On 09/02/2026 03:52, Andres Freund wrote: > > On 2026-02-07 14:59:34 +0200, Heikki Linnakangas wrote: > > > > +/* > > > > + * Try to set a single hint bit in a buffer. > > > > + * > > > > + * This is a bit faster than BufferBeginSetHintBits() / > > > > + * BufferFinishSetHintBits() when setting a single hint bit, but slower than > > > > + * the former when setting several hint bits. > > > > + */ > > > > +bool > > > > +BufferSetHintBits16(uint16 *ptr, uint16 val, Buffer buffer) > > > > > > This could use some more explanation. The point is that this does "*ptr = > > > val", if it's allowed to set hint bits. That's not obvious. And "single hint > > > bit" isn't really accurate, as you could update multiple bits in *ptr with > > > one call. > > > > Agreed. I updated it to > > > > * Try to set hint bits on a single 16bit value in a buffer. > > * > > * If hint bits are allowed to be set, set *ptr = val, try mark the buffer > > * dirty and return true. Otherwise false is returned. > > * > > * *ptr needs to be a pointer to memory within the buffer. > > * > > * This is a bit faster than BufferBeginSetHintBits() / > > * BufferFinishSetHintBits() when setting hints once in a buffer, but slower > > * than the former when setting hint bits multiple times in the same buffer. > > +1. Instead of "try mark the buffer dirty", I'd say just "mark the buffer > dirty". The only reason it might not to mark the buffer dirty is that it was > already marked dirty, right? I wouldn't call that a failure. It's not quite the only reason: /* * If we need to protect hint bit updates from torn writes, WAL-log a * full page image of the page. This full page image is only necessary * if the hint bit update is the first change to the page since the * last checkpoint. * * We don't check full_page_writes here because that logic is included * when we call XLogInsert() since the value changes dynamically. */ if (XLogHintBitIsNeeded() && (lockstate & BM_PERMANENT)) { /* * If we must not write WAL, due to a relfilelocator-specific * condition or being in recovery, don't dirty the page. We can * set the hint, just not dirty the page as a result so the hint * is lost when we evict the page or shutdown. * * See src/backend/storage/page/README for longer discussion. */ if (RecoveryInProgress() || RelFileLocatorSkippingWAL(BufTagGetRelFileLocator(&bufHdr->tag))) return; wal_log = true; } Greetings, Andres Freund