Apache Lucene open-source search software
Enable the vectorized findNextGEQ path on aarch64 (#16254)
Shitij Bhargavabebca0bcc0b7
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 8f740c16cc1..b6b1b6b4b5b 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -141,6 +141,10 @@ ImprovementsOptimizations---------------------+* GITHUB#XXXX: Enable the vectorized findNextGEQ path on aarch64, where it was disabled on cores+ with fewer than 8 int lanes (Graviton2 and Graviton4). The vector compare beats the scalar+ fallback by +75% on Graviton4 and +35% on Graviton2 (AdvanceBenchmark). (Shitij Bhargava)+* GITHUB#15681, GITHUB#15833, GITHUB#16056: Replace pre-sized array or empty array with lambda expression to call Collection#toArray. (Zhou Hui)* GITHUB#13782: Replace handwritten loops compare with Arrays.compareUnsigned in TermsEnum and TermsEnumFrame classes. (Zhou Hui)diff --git a/lucene/core/src/java25/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java b/lucene/core/src/java25/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.javaindex d41118a49b0..3053c1a7f36 100644--- a/lucene/core/src/java25/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java+++ b/lucene/core/src/java25/org/apache/lucene/internal/vectorization/PanamaVectorUtilSupport.java@@ -1128,9 +1128,11 @@ final class PanamaVectorUtilSupport implements VectorUtilSupport {return sum;}- // Experiments suggest that we need at least 8 lanes so that the overhead of going with the vector- // approach and counting trues on vector masks pays off.- private static final boolean ENABLE_FIND_NEXT_GEQ_VECTOR_OPTO = INT_SPECIES.length() >= 8;+ // On x86 we need at least 8 lanes so the overhead of the vector approach plus counting trues on+ // vector masks pays off. On aarch64 the vector path also beats the scalar fallback at 4 lanes+ // (Graviton2 on NEON-128 and Graviton4 on 128-bit SVE2), so enable it there too.+ private static final boolean ENABLE_FIND_NEXT_GEQ_VECTOR_OPTO =+ INT_SPECIES.length() >= 8 || Constants.OS_ARCH.equals("aarch64");@Overridepublic int findNextGEQ(int[] buffer, int target, int from, int to) {