Proposal for enabling auto-vectorization for checksum calculations

From: Matthew Sterrett <matthewsterrett2(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: "Devulapalli, Raghuveer" <raghuveer(dot)devulapalli(at)intel(dot)com>, "Shankaran, Akash" <akash(dot)shankaran(at)intel(dot)com>, Matthew Sterrett <matthewsterrett2(at)gmail(dot)com>
Subject: Proposal for enabling auto-vectorization for checksum calculations
Date: 2025-04-04 22:03:43
Message-ID: CA+vA85_5GTu+HHniSbvvP+8k3=xZO=WE84NPwiKyxztqvpfZ3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,
This patch enables more compiler autovectorization for the checksum
calculations.
This code is particularly well suited for autovectorization, so just
adding pg_attribute_target and some simple dynamic dispatch logic we
can get improved vectorization.
This gives about a 2x speedup in a synthetic benchmark for
pg_checksum, which is also included as a seperate patch file.

Additionally, another 2x performance increase in the synthetic
benchmark with AVX2 can be obtained if N_SUMS was changed to 64.
However, this would change the results of the checksum. This isn't
included in this patch, but I think it is worth considering for the
future

One additional factor, without explicitly passing some optimization
flag like -O2 the makefile build won't autovectorize any of the code.
However, the meson based build does this automatically.

Attachment Content-Type Size
v1-0001-Enable-autovectorizing-pg_checksum_block.patch application/octet-stream 10.5 KB
v1-0002-Benchmark-code-for-postgres-checksums.patch application/octet-stream 4.7 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-04-04 22:06:39 Re: Periodic FSM vacuum doesn't happen in one-pass strategy vacuum.
Previous Message Alexander Lakhin 2025-04-04 22:00:01 Re: SQLFunctionCache and generic plans