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 1vMVJZ-00C1m1-00 for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 17:52:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vMVJW-008frK-1a for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 17:52:54 +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 1vMVJW-008frC-0Q for pgsql-hackers@lists.postgresql.org; Fri, 21 Nov 2025 17:52:54 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vMVJU-000jat-0S for pgsql-hackers@postgresql.org; Fri, 21 Nov 2025 17:52:53 +0000 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-63c489f1e6cso2902251a12.1 for ; Fri, 21 Nov 2025 09:52:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763747570; x=1764352370; 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=XYebK9c1SAHUvii/7aLs8edy86sfCpH/IVhApZKmREE=; b=AMREGRWrzS+SCNTvxIcCeecq0/ad2niG0ookcZueVEairoVGZs4Cf1X1ijdVV5er7o 9pufU9KBNls0INz3JhR7ZVqib7J3POVNIEb6eP3yKJwMiwqlIYLPP8L46ZVkGYQ+oalc abQlnZL/2xxAazaT16zL3PP8m07luqj37oGHO/hyhDA3u3Cx6iJRMoBkLt0djuPdTDKz bgQvex+1OLfGhDvozmVaI7kC8LjiYNLXy8GadCgH50twXEWqXhsVegFpYOzl1RvAFPv5 c0P7me8hdiDApqP9xcJwuDplgXlAVX+grW2qb/aYoUmIzR7EBj+m2pZ2S8wqp6+toQNf 5mTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763747570; x=1764352370; 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=XYebK9c1SAHUvii/7aLs8edy86sfCpH/IVhApZKmREE=; b=UhHmib9IOlH09kmYDVtIsV9yGKpx7Tp0AY90lq+PG1JUwT7k9FMPLFE4wbQ07XEuxF 6971YdAPz9HLPO4tqW0fuqT6Z/noK8HgD4RdOkkRp+bgICeGSKnZge4n0W9K/xvO2qW8 RqcxdfJdLIVRBMSVY83pd/nAOwHzm4Q5ipiGkpxI80tVK2ys4EI63VPd3tZkfuRzWoGI eA4QdeC+SCNVBv/WwClh8Tu+23LD9+Pnz/U7hswVde+Kk6k3qVD1JbAWlS6wPRh1aNpz FaW4zz7635fHq17L27ttalAM6BmPLOjpl2IbWCl2oYrK4gNFLLjDWH8c7+ckl7nO8f3Y WnAg== X-Forwarded-Encrypted: i=1; AJvYcCWxF/QU9T+tca2rM3RFE+uZ0+VyaVxGSj7YUxMSx1Zi6khCbYKpT2yWhqULM903tzQEqxZK82I7d4lojN13@postgresql.org X-Gm-Message-State: AOJu0Yxn5o9KQzWTyJWkNEn/2jDK5eMdXYlSIPHhe6o+SFFKSHTz09qt k0pfvSD7wCIX1QG1JTDMxONdIpkuUg1yIAkgRubE9FHgMAheBnmbgEX7mSZqqz1gr6GXzuqhGvw vbMGKTcHY3nIeyEfK5tl8W/eqikW38k4= X-Gm-Gg: ASbGncvDXoiAldwTKOieEWcrVohLE9v0zYWnqpyAhDDZwB68A4gUfOIAEbSW9h81ZnO oB+UYlbsHyuG4ryDd7kXi6nmGQd9jrunAvlu7AINI2LDo+QUNd1Qnt0fhcqda1LBkIOuk7KSses ILViO51XMHF1RYXBR+nvMKwSH21nVSSFtpVoAVt37lsGbZRooLWRFaAxwjDgYAsK0x2z0a0H5Xj 7IQRhsQXjSuTrVVJa2cRhn5jhQ0Axm9Lles/nPFkMfc5Y+0slSpVPgeRH/X8iC8QoCOkGz2 X-Google-Smtp-Source: AGHT+IFvtOmeYgTdhOkZ2dnITV6gGaOWOKr1qUII/eBJ99ILJVgWVMxWqLzk0H3nMg0aJTucPBwhI8tFzuTf0pvWOPg= X-Received: by 2002:a05:6402:1ecb:b0:640:9997:a229 with SMTP id 4fb4d7f45d1cf-645550783cfmr3267156a12.3.1763747569994; Fri, 21 Nov 2025 09:52:49 -0800 (PST) MIME-Version: 1.0 References: <6kmid26do57ykqfpvq6iieniy4djsymhrypkjccazq5g4bbe6a@2y6owwv7qpex> <3je3ahgf7rrmmurxo6hnlhg5d3ffwfrtjwjxd6jm5srlv5iebp@vxqk5qtgmowr> <3w7v3w6a57jnssokap4k7thoekig72flnyhd4wp3yftzdd7lm7@f6lpcfen6hr7> <6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar> In-Reply-To: <6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar> From: Melanie Plageman Date: Fri, 21 Nov 2025 12:52:38 -0500 X-Gm-Features: AWmQ_bmGm-Qo191l6wExjjJcSRFezvbG-IRHx_PwgSQSHYm8r7bNYYb-Qc58Tv0 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 This email is just a review for some (specified below) of the patches 0001-= 0007 On Wed, Nov 19, 2025 at 9:47=E2=80=AFPM Andres Freund = wrote: > > 0002: Not really required, but seems like an improvement to me The commit message says the point is to get compiler warnings for switch cases that should be exhaustive, but as soon as I looked for a switch case like that, I see BufferIsLockedByMeInMode() switch (mode) { case BUFFER_LOCK_EXCLUSIVE: lw_mode =3D LW_EXCLUSIVE; break; case BUFFER_LOCK_SHARE: lw_mode =3D LW_SHARED; break; default: pg_unreachable(); } Which makes it impossible to get such a warning. When I add a lock mode, it specifically doesn't warn when compiling. However, I'm a big fan of using enums instead of macros when appropriate, so I have no issue with this change. I just think the commit message is a bit confusing. > 0003: A prerequisite to 0004, pretty boring itself LGTM. > 0004: Use 64bit atomics for BufferDesc.state - at this point nothing uses= the > additional bits yet, though. Some annoying reformatting required to avoi= d > long lines. 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. Not related to this patch, but I noticed GetBufferDescriptor() calls for a uint32 and all the callers pretty much pass a signed int =E2=80=94 wonder why it calls for uint32. > 0005: There already was a wait event class for BUFFERPIN. It seems better= to > make that more general than to implement them separately. I reviewed and see no issues with the code, but I don't have an opinion on this wait event naming so maybe you better _wait_ for some other review ;) > 0006+0007: This is preparatory work for 0008, but also worthwhile on its > own. The private refcount stuff does show up in profiles. The reason it's > related is that without these changes the added information in 0008 makes= that > worse. I found it slightly confusing that this commit appears to unnecessarily add the PrivateRefCountData struct (given that it doesn't need it to do the new parallel array thing). You could wait until you need it in 0008, but 0008 is big as it is, so it probably is fine where it is. in InitBufferManagerAccess(), why do you have memset(&PrivateRefCountArrayKeys, 0, sizeof(Buffer)); seems like it should be memset(PrivateRefCountArrayKeys, 0, sizeof(PrivateRefCountArrayKeys)); I wonder how easy it will be to keep the Buffer in sync between PrivateRefCountArrayKeys and the PrivateRefCountEntry =E2=80=94 would a hel= per function help? ForgetPrivateRefCountEntry doesn=E2=80=99t clear the data member =E2=80=94 = but maybe it doesn=E2=80=99t matter... in ReservePrivateRefCountEntry() there is a superfluous clear memset(&victim_entry->data, 0, sizeof(victim_entry->data)); victim_entry->data.refcount =3D 0; 0007 needs a commit message. overall seems fine though. You should probably capitalize the "c" of "count" in PrivateRefcountEntryLast to be consistent with the other names. - Melanie