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 1vLCS2-007wnH-2c for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Nov 2025 03:32:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vLCS1-003fzD-1R for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Nov 2025 03:32:17 +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 1vLCS1-003fz5-0U for pgsql-hackers@lists.postgresql.org; Tue, 18 Nov 2025 03:32:17 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vLCRy-00067G-2V for pgsql-hackers@lists.postgresql.org; Tue, 18 Nov 2025 03:32:16 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b7355774747so63568366b.2 for ; Mon, 17 Nov 2025 19:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763436732; x=1764041532; 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=Pwpi08XFRqubuE1hA9c0lvwMnNKP46vE6IbMnBBlhno=; b=H27PmUYcgG8vTgWncEs68bMxnA4ZM2qekMy+YOCN7H7MIfpwatj5gXTU65DB7NgRPA eGpzugRDc1KdrRsKobuhyunVsembqtd01QFYN2u9H2nZ+4pqHGZEslhq+pynyC2hGzb0 sE7GiQRygwv6mnlOTK9jchaO7iPPxubb0VyGZXcQld/nWTMqmpk4xt1HHbGG6MN/ztAs lOL+uuw8cu9DD+A8WdOLoVi/kCzv2U/c6pq7q26HiNhTJdooHCuScRIc7zbyimk3T+eV RaMD2eeZDNgJonI/1ViZ4r+79Ogf3YICdNkfsVlgpzHrdDy8/doab72kCvJCRw+NesLf qGDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763436732; x=1764041532; 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=Pwpi08XFRqubuE1hA9c0lvwMnNKP46vE6IbMnBBlhno=; b=PE4dvJcr8cSjBHhSDitUA2CVExzIP53IV8e3M7kJ0+TXXM6qYShumtT2Iyy6B1H/kt pIFf3GyBjFh9XySSNI3DgCJS2bar+d4lVpIyIfCDv1wBOOPl4i2ny8fH49Hd3zGtK7Sh CCN1gRbOWfwlljrR70FeENLPbTnwYY09NSvquW8tHeyDU2in4x6J2EA9t1KVditehLNj jKgI0B3oIzNyrXOlgoPthuhOewQim7I6JjDv0HsOuHegRLBXwZDuShFtCSzY2QLia9jm BneufsORDrUT+cIwd1JH4CiMZX8VI8o6E0eGOOzOyDXEOlrYh4vCYYHZXbi4t8SIotlG 9Wpw== X-Gm-Message-State: AOJu0YyoTyeLKkrELi6a9iaPuDqOtjg5XxNRbBN7cMIlMZ+ppeHzPkl/ pvuGJnPiM4up1qwNUv0nIWuYcFi1Dmpun5vO7QsFiVAcnO3KF5NwCDW0/9/8FBzQKNjEbXmPnyd ni3KgFkgmbwa16LRtBaHWZM/V2xIYrffBhxW9ogo= X-Gm-Gg: ASbGnctKNQ3yq7gJmaTWrVi6Wu4hhwVxRiu6RCexR7nozIGTBZr43xCAWm1nXPkO5Op jHN/Ebf8MH7HY85HJ718m+nu5/OAZR+EYfoxkm4x3epfP3seT9xunQ5l82XnOrt1/e2TSBRtxOQ x2CG305krwLnl/+8Kq1xyjHV06lNFvZ2Ez3XFxsYPLmABbtvG1oq9rckl8CSwn/SOgTr5I4io89 uHv/Y2tABfnaVhR+UanjXZ2ncIzc0SwFpm+mmJxDw6AT9CYB4M4bTVwuZq/0A== X-Google-Smtp-Source: AGHT+IGNN10sKUpLGP+zQ98KZJFpTUG4LNUzdn2iIcj752NrZKzJ7PDUVLwdEa4G3dRuXtGotGKPcoJoJzxuMOeQ7nM= X-Received: by 2002:a05:6402:3594:b0:640:b6ef:9dc9 with SMTP id 4fb4d7f45d1cf-6450055c3bbmr651579a12.8.1763436732278; Mon, 17 Nov 2025 19:32:12 -0800 (PST) MIME-Version: 1.0 References: <20250911054220.3784-1-root@ip-172-31-36-228.ec2.internal> In-Reply-To: From: Andrew Kim Date: Mon, 17 Nov 2025 19:32:01 -0800 X-Gm-Features: AWmQ_bk4a-o7UJXZt3ZzKxihCV6PvkWH-NEc1AyPWY0ecKjdLiIi_iiGfkdDQ44 Message-ID: Subject: Re: Proposal for enabling auto-vectorization for checksum calculations To: John Naylor Cc: pgsql-hackers@lists.postgresql.org, Oleg Tselebrovskiy 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 Hi John, Thanks for taking the time to review the v9-0001 refactoring patch and for setting the CF entry to Needs Review. On Fri, Nov 14, 2025 at 3:34=E2=80=AFAM John Naylor wrote: > > On Thu, Nov 6, 2025 at 6:50=E2=80=AFAM Andrew Kim = wrote: > > The v9 patch series is attached. > > Thanks! BTW, I've set the commitfest entry to "Needs Review". > > I spent some time with the v9-0001 refactoring patch, and I have one > observation that's worth sharing now: > > --- a/src/bin/pg_checksums/pg_checksums.c > +++ b/src/bin/pg_checksums/pg_checksums.c > @@ -29,8 +29,7 @@ > #include "getopt_long.h" > #include "pg_getopt.h" > #include "storage/bufpage.h" > -#include "storage/checksum.h" > -#include "storage/checksum_impl.h" > +#include "port/checksum.h" > > Outside the backend it is no longer required to include the > implementation header -- it just links and works correctly. That seems > like a good thing. In fact... > > On Tue, Oct 21, 2025 I wrote: > > Looking at commit f04216341dd1, we have at least one example of an > > external program, pg_filedump. If we can keep this working with > > minimal fuss, it should be fine everywhere. > > > https://github.com/df7cb/pg_filedump/blob/master/pg_filedump.c#L29 > > > > ``` > > /* checksum_impl.h uses Assert, which doesn't work outside the server *= / > > #undef Assert > > #define Assert(X) > > > > #include "storage/checksum.h" > > #include "storage/checksum_impl.h" > > ``` > > I tried building pg_filedump against the server with just the 0001 > patch and it also builds fine leaving out the implementation: > > diff --git a/pg_filedump.c b/pg_filedump.c > index 606a85b..0268381 100644 > --- a/pg_filedump.c > +++ b/pg_filedump.c > @@ -26,12 +26,7 @@ > > #include > > -/* checksum_impl.h uses Assert, which doesn't work outside the serve= r */ > -#undef Assert > -#define Assert(X) > - > -#include "storage/checksum.h" > -#include "storage/checksum_impl.h" > +#include "port/checksum.h" > #include "decode.h" > #include > > I verified that it does in fact break when built against our master > branch without the impl.h header. > > Further, if I replace the above CRC #include to point instead to our > hardware-specific API in port/pg_crc32c.h, it builds fine after > adjusting the typedef that it expects, and interprets the control file > normally: > > ********************************************* > > CRC: Correct > pg_control Version: 1800 > Catalog Version: 202511051 > ... > > I'll think more about this. > I've double-checked everything after applying the v9 checksum patches and updating pg_filedump accordingly. Following your suggestion, I removed the checksum_impl.h include and the Assert redefinition, keeping only the port/checksum.h include. build compiles cleanly with the new architecture, and pg_filedump functions correctly with the AVX2 optimizations. If you agree with this approach, I'd like to prepare a patch for upstream submission. Please feel free to guide me on the proper process for this. Should I submit it to the pg_filedump repository, or would you prefer to handle the integration as part of the v9 checksum patch series? Thanks again for your testing and guidance! > -- > John Naylor > Amazon Web Services