Re: Improve CRC32C performance on SSE4.2
John Naylor <johncnaylorls@gmail.com>
From: John Naylor <johncnaylorls@gmail.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: "Devulapalli, Raghuveer" <raghuveer.devulapalli@intel.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "Shankaran, Akash" <akash.shankaran@intel.com>
Date: 2025-02-13T11:46:10Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Include _mm512_zextsi128_si512() in AVX-512 configure probes.
- ccd5bc93fdfe 18.0 landed
-
Properly fix AVX-512 CRC calculation bug
- 43da394304fb 18.0 landed
-
Workaround code generation bug in clang
- f83f14881c7a 18.0 landed
-
Compute CRC32C using AVX-512 instructions where available
- 3c6e8c123896 18.0 landed
-
Inline CRC computation for small fixed-length input on x86
- e2809e3a1015 18.0 landed
-
Be more paranoid in configure's checks for CRC and POPCNT intrinsics.
- fdb5dd6331e3 18.0 cited
Attachments
- v5-0005-Improve-CRC32C-performance-on-x86_64.patch (application/x-patch) patch v5-0005
- v5-0008-Allow-dev-test-to-build-on-Windows-for-CI-XXX-not.patch (application/x-patch) patch v5-0008
- v5-0006-Unroll-tail.patch (application/x-patch) patch v5-0006
- v5-0007-Fix-32-bit-build.patch (application/x-patch) patch v5-0007
- v5-0004-Run-pgindent-XXX-Some-lines-are-still-really-long.patch (application/x-patch) patch v5-0004
- v5-0002-Vendor-SSE-implementation-from-https-github.com-c.patch (application/x-patch) patch v5-0002
- v5-0003-Adjust-previous-commit-to-match-our-style-add-128.patch (application/x-patch) patch v5-0003
- v5-0001-Add-a-Postgres-SQL-function-for-crc32c-benchmarki.patch (application/x-patch) patch v5-0001
On Thu, Feb 13, 2025 at 4:18 AM Nathan Bossart <nathandbossart@gmail.com> wrote: > > I think the idea behind USE_SSE42_CRC32C is to avoid the function pointer > overhead if possible. I looked at switching to always using runtime checks > for this stuff, and we concluded that we'd better not [0]. > > [0] https://postgr.es/m/flat/20231030161706.GA3011%40nathanxps13 For short lengths, I tried unrolling the loop into a switch statement, as in the attached v5-0006 (the other new patches are fixes for CI). That usually looks faster for me, but not on the length used under the WAL insert lock. Usual caveat: Using small fixed-sized lengths in benchmarks can be misleading, because branches are more easily predicted. It seems like for always using runtime checks we'd need to use branching, rather than function pointers, as has been proposed elsewhere. master: 20 latency average = 3.622 ms latency average = 3.573 ms latency average = 3.599 ms 64 latency average = 7.791 ms latency average = 7.920 ms latency average = 7.888 ms 80 latency average = 8.076 ms latency average = 8.140 ms latency average = 8.150 ms 96 latency average = 8.853 ms latency average = 8.897 ms latency average = 8.914 ms 112 latency average = 9.867 ms latency average = 9.825 ms latency average = 9.869 ms v5: 20 latency average = 4.550 ms latency average = 4.327 ms latency average = 4.320 ms 64 latency average = 5.064 ms latency average = 4.934 ms latency average = 5.020 ms 80 latency average = 4.904 ms latency average = 4.786 ms latency average = 4.942 ms 96 latency average = 5.392 ms latency average = 5.376 ms latency average = 5.367 ms 112 latency average = 5.730 ms latency average = 5.859 ms latency average = 5.734 ms -- John Naylor Amazon Web Services