From 421a35fcdcb2581685dd3942d4b9036bfecb72b9 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 10 Jun 2026 19:55:21 -0700 Subject: [PATCH] Fixed performance regression with Hamming distance and Jaccard distance with Postgres 18 - fixes #985 --- CHANGELOG.md | 4 ++++ src/bitutils.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7f6ec7..fa998ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.3 (unreleased) + +- Fixed performance regression with Hamming distance and Jaccard distance with Postgres 18 + ## 0.8.2 (2026-02-25) - Fixed buffer overflow with parallel HNSW index build - [more info](https://github.com/pgvector/pgvector/issues/959) diff --git a/src/bitutils.c b/src/bitutils.c index 366e670..8e24c99 100644 --- a/src/bitutils.c +++ b/src/bitutils.c @@ -32,9 +32,9 @@ #endif /* Use built-ins when possible for inlining */ -#if defined(HAVE__BUILTIN_POPCOUNT) && defined(HAVE_LONG_INT_64) +#if defined(HAVE__BUILTIN_POPCOUNT) && (defined(HAVE_LONG_INT_64) || SIZEOF_LONG == 8) #define popcount64(x) __builtin_popcountl(x) -#elif defined(HAVE__BUILTIN_POPCOUNT) && defined(HAVE_LONG_LONG_INT_64) +#elif defined(HAVE__BUILTIN_POPCOUNT) && (defined(HAVE_LONG_LONG_INT_64) || SIZEOF_LONG_LONG == 8) #define popcount64(x) __builtin_popcountll(x) #elif !defined(_MSC_VER) /* Fails to resolve with MSVC */