Re: Proposal for enabling auto-vectorization for checksum calculations

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Andrew Kim <tenistarkim(at)gmail(dot)com>
Cc: Oleg Tselebrovskiy <o(dot)tselebrovskiy(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Proposal for enabling auto-vectorization for checksum calculations
Date: 2026-03-17 02:23:25
Message-ID: CANWCAZbigzGc_Kzsqf3NB+FgfnvJCas_KovCXg3GROJTVjuS9Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 16, 2026 at 3:00 PM Andrew Kim <tenistarkim(at)gmail(dot)com> wrote:
>
> It looks like your PostgreSQL build on Cirrus CI is failing during the
> Meson configuration phase because it cannot find the libedit
> libraries.
> Should we add these to the pacman installation command in our CI
> scripts, or is there a preferred way to handle terminal library
> dependencies for the Windows Meson builds?

I'll leave that to the people who maintain it. Sometimes intermittent
glitches happen. And please don't top-post.

I've attached v12 which is just a rebase over the new centralized
feature detection. I also have some review:

+# Check if the compiler supports AVX2 target attribute.
+# This is used for optimized checksum calculations with runtime detection.

It could possibly be used for other things, in which case this will
get out of date. It's most reliable to grep for the symbol to see
where something is used.

Also, the first statement is not true:

+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>
+ #if defined(__has_attribute) && __has_attribute (target)
+ __attribute__((target("avx2")))
+ static int avx2_test(void)
+ {
+ return 0;
+ }
+ #endif],

With these guards, I think any compiler will pass the test, and CI
does show it passes on MSVC:

[01:09:52.888] Checking if "AVX2 support" links: YES

The consequence is that two functions get built with identical
non-AVX2 contents. Then at runtime we pick one of them, but it doesn't
matter which. This needs to test what it says it's testing.

--
John Naylor
Amazon Web Services

Attachment Content-Type Size
v12-0001-Benchmark-code-for-postgres-checksums.patch text/x-patch 4.9 KB
v12-0002-Adjust-benchmark-to-use-core-checksum.patch text/x-patch 1.6 KB
v12-0003-Enable-autovectorizing-page-checksums-with-AVX2-.patch text/x-patch 13.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-03-17 02:25:22 Re: Proposal for enabling auto-vectorization for checksum calculations
Previous Message Sami Imseih 2026-03-17 02:12:17 Re: Refactor query normalization into core query jumbling