Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.MMapDirectory;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.VectorUtil;
import org.apache.lucene.util.hnsw.RandomVectorScorer;
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
import org.apache.lucene.util.hnsw.UpdateableRandomVectorScorer;
Expand Down Expand Up @@ -91,6 +92,11 @@ public void init() throws IOException {
.getRandomVectorScorerSupplier(DOT_PRODUCT, vectorValues)
.scorer();
scorer.setScoringOrdinal(0);

// Pollute call site!
for (int i = 0; i < 10_000_000; i++) {
VectorUtil.dotProduct(vec1, vec2);
}
}

@TearDown
Expand All @@ -109,6 +115,17 @@ public float binaryDotProductMemSeg() throws IOException {
return scorer.score(1);
}

@Benchmark
@Fork(
jvmArgsPrepend = {
"--add-modules=jdk.incubator.vector",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:CompilerDirectivesFile=lucene/benchmark-jmh/src/resources/vector-directives.json"
})
public float binaryDotProductMemSegWithVectorDirectives() throws IOException {
return scorer.score(1);
}

static KnnVectorValues vectorValues(
int dims, int size, IndexInput in, VectorSimilarityFunction sim) throws IOException {
return new OffHeapByteVectorValues.DenseOffHeapVectorValues(
Expand Down
9 changes: 9 additions & 0 deletions lucene/benchmark-jmh/src/resources/vector-directives.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"match": [ "org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport::*" ],
"inline": [
"-org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport$ArrayLoader::*",
"-org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport$MemorySegmentLoader::*"
]
}
]
Loading