From c9aa09d5a182acce649dd1e41c65950258713efa Mon Sep 17 00:00:00 2001 From: Samuel Herman Date: Fri, 21 Feb 2025 22:01:28 -0800 Subject: [PATCH 1/6] add jmh skeleton Signed-off-by: Samuel Herman --- benchmarks-jmh/README.md | 37 +++++ benchmarks-jmh/pom.xml | 127 ++++++++++++++++++ .../jvector/bench/RandomVectorsBenchmark.java | 34 +++++ pom.xml | 1 + 4 files changed, 199 insertions(+) create mode 100644 benchmarks-jmh/README.md create mode 100644 benchmarks-jmh/pom.xml create mode 100644 benchmarks-jmh/src/main/java/io/github/jbellis/jvector/bench/RandomVectorsBenchmark.java diff --git a/benchmarks-jmh/README.md b/benchmarks-jmh/README.md new file mode 100644 index 00000000..dbd0b31f --- /dev/null +++ b/benchmarks-jmh/README.md @@ -0,0 +1,37 @@ +# JMH Benchmarks +Micro benchmarks for jVector. While {@link Bench.java} is about recall, the JMH benchmarks +are mostly targeting scalability and latency aspects. + +## Building and running the benchmark + +1. You can build and then run +```shell +mvn clean install +java --enable-native-access=ALL-UNNAMED \ + --add-modules=jdk.incubator.vector \ + -XX:+HeapDumpOnOutOfMemoryError \ + -Xmx14G -Djvector.experimental.enable_native_vectorization=true \ + -jar benchmarks-jmh/target/benchmarks-jmh-4.0.0-beta.2-SNAPSHOT.jar +``` +2. Build and run the benchmarks directly +```shell +mvn clean package -pl :benchmarks-jmh -am -DskipTests=true exec:exec@benchmark -Pjmh +``` +3. Build and run a specific benchmark or use command line arguments +```shell +# Run only benchmarks containing "Sample" in their name +mvn clean package -pl :benchmarks-jmh -am -DskipTests=true exec:exec@benchmark -Pjmh -DargLine=".*Sample.*" + +# Run with different parameters +mvn clean package -pl :benchmarks-jmh -am -DskipTests=true exec:exec@benchmark -Pjmh -DargLine="-f 1 -wi 5 -i 3 .*Sample.*" +``` + +Common JMH command line options you can use in the configuration or command line: +- `-f ` - Number of forks +- `-wi ` - Number of warmup iterations +- `-i ` - Number of measurement iterations +- `-w