Skip to content
Open
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
24 changes: 23 additions & 1 deletion src/python/knnPerfTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import re
import subprocess
import sys

import shutil
import benchUtil
import constants
from common import getLuceneDirFromGradleProperties
Expand All @@ -35,6 +35,12 @@

DO_PROFILING = False


# Set this to True to generate the disassembled code to verify the intended SIMD instructions are getting used or not
PERF_MODE = False

PERF_PATH = shutil.which("perf")

# e.g. to compile KnnIndexer:
#
# javac -d build -cp /l/trunk/lucene/core/build/libs/lucene-core-10.0.0-SNAPSHOT.jar:/l/trunk/lucene/join/build/libs/lucene-join-10.0.0-SNAPSHOT.jar src/main/knn/*.java src/main/WikiVectors.java src/main/perf/VectorDictionary.java
Expand Down Expand Up @@ -179,6 +185,7 @@ def run_knn_benchmark(checkout, values):

cmd += ["knn.KnnGraphTester"]

index_run = 1
all_results = []
while advance(indexes, values):
if NOISY:
Expand Down Expand Up @@ -238,6 +245,17 @@ def run_knn_benchmark(checkout, values):
#'-quiet'
]
)
if PERF_MODE and PERF_PATH:
print("Will be recording the executed instructions in perf.data file")
perf_cmd = [PERF_PATH, "record", "-e", "instructions:u", "-o", f"perf{index_run}.data", "-g"] + this_cmd
job = subprocess.run(perf_cmd)
if NOISY:
print(f" cmd: {perf_cmd}")
index_run += 1
continue
elif PERF_MODE:
print("'perf' tool not found with perf mode enabled. Please install 'perf' tool locally")
sys.exit(1)
if NOISY:
print(f" cmd: {this_cmd}")
else:
Expand All @@ -264,6 +282,10 @@ def run_knn_benchmark(checkout, values):
all_results.append((summary, args))
if DO_PROFILING:
benchUtil.profilerOutput(constants.JAVA_EXE, jfr_output, benchUtil.checkoutToPath(checkout), 30, (1,))
index_run += 1

if PERF_MODE:
return

if NOISY:
print("\nResults:")
Expand Down
Loading