Skip to content

Commit 86c3bf9

Browse files
committed
iter
1 parent 9a341c9 commit 86c3bf9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/vector/Int4ScorerBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class Int4ScorerBenchmark {
5252
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
5353
}
5454

55-
@Param({ "1024" })
55+
@Param({ "384", "702", "1024" })
5656
int dims;
5757

5858
int numVectors = 200;

libs/simdvec/src/main/java/org/elasticsearch/simdvec/ES91Int4VectorsScorer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ public class ES91Int4VectorsScorer {
2323
/** The wrapper {@link IndexInput}. */
2424
protected final IndexInput in;
2525
protected final int dimensions;
26+
protected byte[] scratch;
2627

2728
/** Sole constructor, called by sub-classes. */
2829
public ES91Int4VectorsScorer(IndexInput in, int dimensions) {
2930
this.in = in;
3031
this.dimensions = dimensions;
32+
scratch = new byte[dimensions];
3133
}
3234

3335
public long int4DotProduct(byte[] b) throws IOException {
36+
in.readBytes(scratch, 0, dimensions);
3437
int total = 0;
3538
for (int i = 0; i < dimensions; i++) {
36-
total += in.readByte() * b[i];
39+
total += scratch[i] * b[i];
3740
}
3841
return total;
3942
}

libs/simdvec/src/main21/java/org/elasticsearch/simdvec/internal/vectorization/MemorySegmentES91Int4VectorsScorer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public long int4DotProduct(byte[] q) throws IOException {
6161
i += BYTE_SPECIES_128.loopBound(dimensions);
6262
res += int4DotProductBody128(q, i);
6363
}
64-
64+
in.readBytes(scratch, i, dimensions - i);
6565
while (i < dimensions) {
66-
res += in.readByte() * q[i++];
66+
res += scratch[i] * q[i++];
6767
}
6868
return res;
6969
}

0 commit comments

Comments
 (0)