Re: Proposal for enabling auto-vectorization for checksum calculations
John Naylor <johncnaylorls@gmail.com>
From: John Naylor <johncnaylorls@gmail.com>
To: Andrew Kim <tenistarkim@gmail.com>
Cc: Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>,
pgsql-hackers@lists.postgresql.org
Date: 2026-03-30T12:01:02Z
Lists: pgsql-hackers
Attachments
- v13-0001-Enable-autovectorizing-page-checksums-with-AVX2-.patch (text/x-patch) patch v13-0001
On Tue, Mar 17, 2026 at 9:23 AM John Naylor <johncnaylorls@gmail.com> wrote: > I've attached v12 which is just a rebase over the new centralized > feature detection. I also have some review: Andrew Kim let me know he is not available at this time, so since I found only minor issues and we're close to feature freeze I took care of them myself in the attached v13. I also further updated an outdated comment to reflect that some compilers (for the archives: at least gcc 8.5 and up) can turn a multiplication by a constant into shifts and adds (the FNV prime is pretty sparse in one-bits), so it's no longer true that vector multiplication is required. That works on SSE2 and powerpc, at least. I don't remember the last time anyone did measurements, so I went ahead and did that: master: 945ms 32 AVX2: 335ms 64 AVX2: 220ms The last one is just to verify an old code comment, and assertion in this thread, that the choice of 32 accumulators left some performance on the table. (Even if it weren't in diminishing returns territory, we wouldn't consider raising this because that changes the computed value, but if I'm updating comments anyway, I wanted to check as much as convenient.) I'll repeat building pg_filedump with this and if that goes well I plan to push this week unless there are objections. -- John Naylor Amazon Web Services
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use AVX2 for calculating page checksums where available
- 5e13b0f24039 19 (unreleased) landed
-
Refactor checksumming code to make it easier to use externally.
- f04216341dd1 9.3.0 cited