Introduce optimized routine for linear searches of arrays

Enterprise / PostgreSQL - John Naylor [postgresql.org] - 10 August 2022 03:48 UTC

Use SSE2 intrinsics to speed up the search, where available. Otherwise, use a simple 'for' loop. The motivation to add this now is to speed up XidInMVCCSnapshot(), which is the reason only unsigned 32-bit integer arrays are optimized. Other types are left for future work, as is the extension of this technique to non-x86 platforms.

Nathan Bossart

Reviewed by: Andres Freund, Bharath Rupireddy, Masahiko Sawada Discussion: https://postgr.es/m/20220713170950.GA3116318%40nathanxps13

b6ef167564 Introduce optimized routine for linear searches of arrays
src/include/port/pg_lfind.h | 103 +++++++++++++++++++++
src/test/modules/Makefile | 1 +
src/test/modules/test_lfind/.gitignore | 4 +
src/test/modules/test_lfind/Makefile | 23 +++++
.../modules/test_lfind/expected/test_lfind.out | 12 +++
src/test/modules/test_lfind/sql/test_lfind.sql | 8 ++
src/test/modules/test_lfind/test_lfind--1.0.sql | 8 ++
src/test/modules/test_lfind/test_lfind.c | 52 +++++++++++
src/test/modules/test_lfind/test_lfind.control | 4 +
9 files changed, 215 insertions(+)

Upstream: git.postgresql.org


  • Share