RoanHeNaN opened a new pull request, #447: URL: https://github.com/apache/doris-thirdparty/pull/447
### What problem does this PR solve? `faiss/impl/ScalarQuantizer.cpp` enables the NEON scalar-quantizer kernels with: ```cpp #if defined(__aarch64__) #if defined(__GNUC__) && __GNUC__ < 8 #warning "Cannot enable NEON optimizations in scalar quantizer if the compiler is GCC<8" #else #define USE_NEON #endif #endif ``` The check was added for GCC 7 (upstream facebookresearch/faiss#3869), but clang always defines `__GNUC__` as 4 for GCC compatibility, so it matches every clang build. Doris builds BE with clang (ldb_toolchain), so on aarch64 `USE_NEON` is never defined and only the scalar `SIMDWIDTH=1` distance computers are compiled. Every sq8 / sq4 IVF and HNSW search on ARM runs the scalar path. ### Fix Exclude clang from the GCC version check: ```cpp #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 ``` Upstream faiss removed the guard as a side effect of the scalar-quantizer SIMD refactor (facebookresearch/faiss#4839, first released in v1.14.1), where NEON is enabled by CMake. This branch is based on v1.11, so it still has the guard. ### Evidence - `objdump -d -C ScalarQuantizer.cpp.o` built with clang 20 on aarch64: `SimilarityIP<8>` (NEON) references go from 0 to 1388. `SimilarityIP<1>` stays at 2317. - Doris BE on AWS Graviton (16 vCPU), IVF_ON_DISK sq8, dim 2048, 16 segments x 312,500 rows, nlist 2461, 200 queries, warm cache: | nprobe | recall@10 before -> after | exec p50 (ms) | ANN CPU sum (ms) | CPU speedup | |---|---|---|---|---| | 20 | 0.9765 -> 0.9760 | 16 -> 13 | 122.9 -> 94.2 | 1.30x | | 77 | 0.9930 -> 0.9925 | 39 -> 28 | 388.1 -> 270.1 | 1.44x | | 154 | 0.9950 -> 0.9945 | 65 -> 49 | 737.2 -> 513.0 | 1.44x | | 308 | 0.9965 -> 0.9960 | 113.5 -> 82 | 1434.8 -> 983.5 | 1.46x | Recall differs by at most 0.0005 (a different float summation order in the SIMD path). x86 is not affected: its AVX2 / AVX-512 paths are gated on `__AVX2__` / `__AVX512F__`. ### Follow-up (not in this PR) The NEON `Codec8bit::decode_8_components` / `Codec4bit::decode_8_components` still decode the 8 components with a scalar loop into a stack array and reload them with `vld1q_f32`. Upstream `sq-neon.cpp` has the same code. After this fix, perf still shows ~74-86% of IVF-SQ8 search time in `distance_to_code`, so a vectorized u8 -> float decode is a further opportunity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
