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 1vQAi4-000eUI-2T for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Dec 2025 20:41:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQAi3-004NMG-2f for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Dec 2025 20:41:24 +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 1vQAi3-004NM8-1g for pgsql-hackers@lists.postgresql.org; Mon, 01 Dec 2025 20:41:23 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQAi1-002cHz-2g for pgsql-hackers@postgresql.org; Mon, 01 Dec 2025 20:41:23 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-640c1fda178so8923947a12.1 for ; Mon, 01 Dec 2025 12:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764621679; x=1765226479; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QgcbtVaSo10RKGNKVwfGdMrQbQ1WvNdneYUn6yyCQ2w=; b=j/9ynIRmcU/sf6XYKkQ7kEthj1NWk3R9T7/ImH0c1Dt678aOOAjfc5eQOnUUJ/Yl4F m9i/42qQx3Yyze0MunPRpTINJ172Y3Voi7h6cVhTKcaQ8nU1cBx767ROV0n3weAXcyl4 TOlRia+AhGSbopJISXuJup6ayMhZcBX8TdAUOiencVVYUoxyL9QyUJ4AtdH/mhtvRfWx eZr30ebCBJ6rw6CiIoNGDAZe42kKec8oVhu8torOTNHOW8kYPghuOVDb+oeeVHQqAuwu mPrThpSbyIsLe9fQI+3UqbcUAGzI2U9NoDy6h/BcGVu8CasG9mL8YDNfxB+y3+Agj1yu EbKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764621679; x=1765226479; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QgcbtVaSo10RKGNKVwfGdMrQbQ1WvNdneYUn6yyCQ2w=; b=lylpoZ/NGUGFS2jM2azGp59qMoXo6Pjhcg5o7+IE2hw/54KPjoUkuxV2AFX8RaGbQI yZv/bmMXw2uHSItDMTteHpxhLuPfzXpLPGeGgevNAM8XjU1QR+Kd6gCkNGAZh0FJfqXI Pza9TiJvdht+klCVYYO6WKJQM59PvvIgtg6e+lRj9g5C/UcAEZlJhFZOnMW5dizf9u/4 HgbEKOZyOYghAOB3wAuZdpIkmFCEViInIwejPii8E9Bp4q64c1kGMhnqSQMlo7wtJ5nm yI1d6LTHQE9Md2eaiDdmDpqNQK0B83ApcWEqycOsi9e2Ht1wrnfItQ3gMgCdhyvxTQMd uKHQ== X-Forwarded-Encrypted: i=1; AJvYcCXB5VJM4xHqtaCz30HAwR9H4prFc2GofaRtNJtshDpdHqEyAuexi/2chgET7cPXu7atTlpth6u+Mt2qvUXD@postgresql.org X-Gm-Message-State: AOJu0Ywxe1YfNFvXu3Af7E+2PlyVgc1a0HiHxJUaTQ0UdUkv4jzCTWXd 6LiiKXZK5XFRra3l9woimOIzhWNQOfO1STRvHmEe5buxevpNnY7soFKuKBhOsoVVFN5fS4+E2JD zbkkaHBlSBR4oa+cxtTyYwTW/1J+X/QE= X-Gm-Gg: ASbGnctSib447zsOwPvGfqmJWB1QZSiX907m4wjuom3qD7MY9W7U4POSWcjcJKPZjND QpIKB1HuGKaA5FoY57mHLrC7qHGsVfMZTqtfKl30C5TkfnAlvwVTU6uB8e6hiZ7FeTA8uVpX3AR 7UO0qkHJdlYseD6583jUg3xu6njrO7iWMVZTNpgbzzCaFe2nLnjCsrcOT2iyMhV3BV8EJcLi8Qg zzBH1SGU1KPrTxYhE2ZdSfRkLQRw08xnCmDilNWcmPPuIkd7TBwyxXsV0sFLH9yxMOpBakh X-Google-Smtp-Source: AGHT+IG6HZ7W/ANnKET3kqcF3l6DKBz/b3AnuES44blupOydzgkfNVSPRGXm8xJq6RuKdAmyBK7TTjg/nhOyTPQ0/RU= X-Received: by 2002:a05:6402:4316:b0:647:57db:c997 with SMTP id 4fb4d7f45d1cf-64757dbc9e3mr13611339a12.21.1764621678679; Mon, 01 Dec 2025 12:41:18 -0800 (PST) MIME-Version: 1.0 References: <6kmid26do57ykqfpvq6iieniy4djsymhrypkjccazq5g4bbe6a@2y6owwv7qpex> <3je3ahgf7rrmmurxo6hnlhg5d3ffwfrtjwjxd6jm5srlv5iebp@vxqk5qtgmowr> <3w7v3w6a57jnssokap4k7thoekig72flnyhd4wp3yftzdd7lm7@f6lpcfen6hr7> <6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar> In-Reply-To: From: Melanie Plageman Date: Mon, 1 Dec 2025 15:41:07 -0500 X-Gm-Features: AWmQ_bkPDdWqaPMa0ODrcwNa3P9Vv0hH6nqSivTSdmTh6VFGfWMPxp9ltkixvvk Message-ID: Subject: Re: Buffer locking is special (hints, checksums, AIO writes) To: Andres Freund Cc: Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Heikki Linnakangas , Noah Misch , Robert Haas , Michael Paquier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Dec 1, 2025 at 3:28=E2=80=AFPM Andres Freund w= rote: > > > I noticed that the BUF_STATE_GET_REFCOUNT and BUF_STATE_GET_USAGECOUNT > > macros cast the return value to a uint32. We won't use the extra bits > > but we did bother to keep the macro result sized to the field width > > before so keeping it uint32 is probably more confusing now that state > > is 64 bit. > > I can't really follow - why would we want to return a 64bit value if none= of > the values ever can get anywhere near that big? Well, usagecount could never have reached anything close to a uint32 either, so I thought that this cast was meant to match the datatype. I found it rather confusing otherwise. > > 0007 > > needs a commit message. overall seems fine though. > > This is what I've since written: > > bufmgr: Add one-entry cache for private refcount > > The private refcount entry for a buffer is often looked up repeatedly= for the > same buffer, e.g. to pin and then unpin a buffer. Benchmarking shows = that it's > worthwhile to have a one-entry cache for that case. With that cache i= n place, > it's worth splitting GetPrivateRefCountEntry() into a small inline > portion (for the cache hit case) and an out-of-line helper for the re= st. > > This is helpful for some workloads today, but becomes more important = in an > upcoming patch that will utilize the private refcount infrastructure = to also > store whether the buffer is currently locked, as that increases the r= ate of > lookups substantially. Sounds good based on what I recall of the patch. - Melanie