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.94.2) (envelope-from ) id 1urFtO-0037eP-3V for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 13:08:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1urFtM-00FEk0-NN for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 13:08:45 +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.94.2) (envelope-from ) id 1urFtM-00FEji-Dt for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 13:08:45 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1urFtJ-00299M-34 for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 13:08:43 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-6188b5b113eso8774481a12.0 for ; Wed, 27 Aug 2025 06:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756300121; x=1756904921; darn=lists.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=0SyXArFqoDU3yk3PmYqLSkGU8O/wtvV4VfLZJDSnu0A=; b=mxU8CHbKkOdL+PrR/rCUotMmFSktJj4/njwyS+DvTlP32rd7SnsmoBvEc1bpL70GlX 0H9vvLBkLRcspIL+SXxgqKufg2wwrRrkXJyOahdS71YvrXHuTzXsys++n+byyJ+ood8W IoDirFSWkoRCJgaMIf8JpLbDl7UIQMulQpWJF/MaXrP5t9pe9kjqhf/80RPyo+a6AtoO FkBHTozrIWUgBnFXizY6qVNVTOhN8gtsEdUTWhbbQdqgN7thoRoLRQqL2kcbNbqCqdx9 XGGi0sqDhtehqqc5dE1m0IflUsPKXGQhqUHg25GPPfArOn+qpxgxJnDnkxKbcB5mxtmC 6OUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756300121; x=1756904921; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0SyXArFqoDU3yk3PmYqLSkGU8O/wtvV4VfLZJDSnu0A=; b=iZ5hxzNMfACHDhEyLwTtjKrkdxNUj2mP4WmTu+WYTXDW9cZOMBfFj2u07BxTU05KJK YfitqpN2jy7skGHFIfXqoeqrahGVxlNMW2eXKb3pr0csgDoHuajJmnjEVWKzqjRBSd/m htdS5F+bdXcy/3/EBHu7Ai3uSgOkSELRfO32CsUjvBqpMl+27NN4usuLxEOEi2xf9S7E O/42AnbcbLiwX9lrB7VONnT3Eo9k4UNL490nGdO2jot8gg3E84s/U5f01ezf9nIvYIG8 uifHdAMLnzooFuW0wPpqn3b6CXvYjhimKRkLqezJ4y9lYklLf6Nh/6650TWwqU3Q4+r7 d70Q== X-Forwarded-Encrypted: i=1; AJvYcCUgAEuBYVkxIl2BOKDx+aB+XDTR16h5PsHKNbZT8vNpkFrHc3Y7U30VnrXBCWPz5DDqgARelfsoUkCmt5un@lists.postgresql.org X-Gm-Message-State: AOJu0YwOi5VzBV/KCN+Dfiqc5PQ3qfukhSAIZBMR1hWzfjP6+EVRxMsf VDR+16NjBOV4rF2p8gTT2SmBkhRE1o3Ia+4ruXoWweoz6DRAPGkQ6TQx1EnZgS+P753vWNGwQdx Kc/cUDCdLwkqTzq6dakyc2B2fh/wqYLKp+Qqi X-Gm-Gg: ASbGncuy8wNGC639odfDAJ/GiYgL+ZcnzvRiWtDOPsY3PWo582GRh/KzbZrAO7wmYO8 jmbie7pBWNduyWABbG9ciDmEDfKWz1OPCO1RA1dv+o9mBFV5SVSzTB+sfM5CsC+4gbH9K737A7c K0m2KqJLOyMeYlmqojspjOAyh3x9hJ+NFbti06haIvfQgHgJc7/G+gzcujoegp5mEsf3Eugrn5C YWV1WA= X-Google-Smtp-Source: AGHT+IE+S+tChJZOj+rivsMpVWjJUTxx7jUN6pIFR8FAGHr+xw5MqdXiFtvRsAcFrXIfOj9q9JCtlwn0qDapMCOHdMg= X-Received: by 2002:a05:6402:5109:b0:61c:5d0c:9383 with SMTP id 4fb4d7f45d1cf-61c5d0c9c0fmr10969554a12.24.1756300120307; Wed, 27 Aug 2025 06:08:40 -0700 (PDT) MIME-Version: 1.0 References: <87DD95AA-274F-4F4F-BAD9-7738E5B1F905@yandex-team.ru> In-Reply-To: From: Melanie Plageman Date: Wed, 27 Aug 2025 09:08:28 -0400 X-Gm-Features: Ac12FXxTFtyCjX-BQZ7QTUvDrpmSrQNdW9ZbP-xboInrGT_eIJxUgpBL_IxkvIc Message-ID: Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Kirill Reshke Cc: Andrey Borodin , PostgreSQL Hackers , Andres Freund , Robert Haas 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 Thanks for all the reviews. I'm working on responding to your previous mails with a new version. On Wed, Aug 27, 2025 at 8:55=E2=80=AFAM Kirill Reshke wrote: > > v6-0015: > I chose to verify whether this single modification would be beneficial > on the HEAD. > > Benchmark I did: > > ``` > > \timing > CREATE TABLE zz(i int); > alter table zz set (autovacuum_enabled =3D false); > TRUNCATE zz; > copy zz from program 'yes 2 | head -n 180000000'; > copy zz from program 'yes 2 | head -n 180000000'; > > delete from zz where (REPLACE(REPLACE(ctid::text, '(', '{'), ')', > '}')::int[])[2] =3D 7 ; > > VACUUM FREEZE zz; > ``` > > And I checked perf top footprint for last statement (vacuum). My > detailed results are attached. It is a HEAD vs HEAD+v6-0015 benchmark. > > TLDR: function inlining is indeed beneficial, TransactionIdPrecedes > function disappears from perf top footprint, though query runtime is > not changed much. So, while not resulting in query speedup, this can > save CPU. > Maybe we can derive an artificial benchmark, which will show query > speed up, but for now I dont have one. I'm not surprised that vacuum freeze does not show a speed up from the function inlining. This patch was key for avoiding a regression in the most contrived worst case scenario example of setting the VM on-access. That is, if you are pruning only a single tuple on the page as part of a SELECT query that returns no tuples (think SELECT * FROM foo OFFSET N where N is greater than the number of rows in the table), and I add determining if the page is all visible, then the overhead of these extra function calls in heap_prune_record_unchanged_lp_normal() is noticeable. We might be able to come up with a similar example in vacuum without freeze since it will try to determine if the page is all-visible. Your example is still running on my machine, though, so I haven't verified this yet :) - Melanie