Skip to content

Benchmarks

Experimental. The API is not stable and nothing here is wired into a database engine yet. What may change.

The harness is src/bench/java/ai/humem/tiervec/Bench.java. It builds a TieredIndex from seeded data, compares every answer with an exact scan that it computes itself, and writes one result file that names the machine, the JDK and the commit. It measures one question set: recall and latency of the tier at a size, unfiltered and filtered, and what happens when writers and searchers run at once. Issue #12 (the range of allowed shares where an exact scan beats the graph walk) is the first user.

The vectors are generated by default. Two options replace parts of that: --data reads a real embedding set that a script prepared, and --engine jvector builds and searches the same data with JVector at the same M and efConstruction, so that the two result files can be read line by line (issue #108). Without these two options a run is the run it was before they existed.

Numbers from the harness are directional unless a study states its claim, its arms, its number of runs and its bound before it runs (see "How to read measurements" in ROADMAP.md). One run is one sample. A result file says what the run did on one machine, not what the library does on every machine.

Run it

Maven does not compile the harness, as with src/smoke. Compile it with the library sources, and run it with the Vector API module (the module is optional for the library, but a result without it is a different measurement, and the file records which one ran):

mkdir -p target/bench/classes
find src/main/java src/bench/java -name '*.java' > target/bench/sources.txt
javac -d target/bench/classes --add-modules jdk.incubator.vector @target/bench/sources.txt
java -Xmx14g --add-modules jdk.incubator.vector -cp target/bench/classes ai.humem.tiervec.Bench \
  --host-label my-laptop --out results/$(date +%F)-my-laptop.txt

With no options this is the 1,000,000-vector run: dimension 768, cosine, k = 10, ef = 100, 200 queries with 5 timed passes, allowed shares 0.5, 0.1, 0.01 and 0.001 each with filterScanBelow off and on, then 10 minutes of concurrent writers and searchers. Every option is a --key value pair, and the list with the defaults is the method Bench.defaults(). The ones that matter most:

Option Default Meaning
--n, --dim, --k, --ef 1000000, 768, 10, 100 Vectors, dimension, answers per query, beam width of a segment search
--seed 42 Seed of the data, the queries and the filter. The same seed gives the same vectors on every JVM (the DATA line has a checksum)
--ef-sweep 20,50,200,400 Extra unfiltered cells at these beam widths, a recall curve like the one of GraphTest bench. The recall floors do not apply to them
--queries, --reps 200, 5 Distinct queries, and timed passes over them per cell (after one warm-up pass that also measures recall)
--shares 0.5,0.1,0.01,0.001 Allowed shares of the filtered cells
--scan-below 0,1 filterScanBelow values of the filtered cells. 0 is off (the walk, with its fallback to a scan). 1 scans first at every share
--tail-limit, --small-limit, --max-segments, --merge-fan, --build-threads the library defaults The tier configuration. --build-threads 0 keeps the default of TieredIndex.Config
--load add add calls TieredIndex.add n times and waits until no seal or merge is due. rebuild makes one rebuildFrom
--settle none merge calls mergeNow() after the build, so the searches run on one segment
--conc-seconds 600 Length of the concurrent phase. 0 skips it
--writers, --searchers 2, 2 Threads of the concurrent phase. There is one more thread that deletes
--write-rate, --delete-rate 500, 100 Adds and deletes per second over all threads. 0 for adds is unthrottled
--min-recall, --min-scan-recall 0, 0 Recall floors. With 0 the harness reports and does not fail on recall. The CI smoke sets both
--host-label the host name The name of the machine in the file. The file is meant to be committed to a public repository, so give a label that says what the machine is and not who owns it
--out none The result file. The same lines go to standard output
--data none A directory that scripts/prep_real_dataset.py wrote (or the path of a file in it): the vectors, the queries and the exact answers come from the files. See Real data
--engine tiervec tiervec, or jvector, the comparison arm. See The JVector arm
--jvector-alpha, --jvector-overflow 1.2, 1.2 JVector only: the pruning alpha and the neighbor overflow while building. They are the values of the JVector tutorial, and they have no tier counterpart in the same form (the tier uses alpha 1.0)
--quant none none is float32. With the tier, sq8 builds the segment graphs with SQ8 codes (the walk uses the codes, and the ef candidates are scored again in float32). With JVector, int8 builds and walks the graph on int8 vectors, see The JVector arm
--targets, --ef-grid none, 33 widths from 10 to 1000 Recall targets such as 0.95,0.99, and the beam widths to try. See Latency at matched recall
--disk none An empty or new directory. The index is written there after the searches (the tier: sealNow and checkpoint; JVector: one graph file) and the DISK line gives the file sizes
--props 0 The tier only, with --conc-seconds 0: this many new ids and this many reused ids in the checks of the writes

Latency at matched recall

This compares two indexes at the same recall and not at the same beam width. With --targets, after the SEARCH cells and for each search mode, the harness tries the beam widths of --ef-grid from the smallest until the highest target is reached (MATCH-SWEEP, one pass over the queries each). For each target it times the first width that reaches it and the width before it (MATCH-TIMED: one warm-up pass, then --reps timed passes), and interpolates p50, p99 and the mean linearly in recall between the two (MATCHED). status=floor says that the smallest width of the grid reached the target already, so the latency is the one of that width. status=unreached says that no width of the grid reached it. The queries per second of a MATCHED line are those of one search thread.

Checks of the writes

--props N checks what the tier promises to a host and a static comparison does not show. It adds N new vectors and searches for each one at once; then it deletes N ids of the build, searches, adds each id again with another vector and searches for both the new and the old vector; then it seals the tail, waits until the tier is idle and repeats the searches. The run fails when a written vector is not in the answer of the next search, when a deleted id is returned, when an id answers with the score of its old vector, or when the live count is wrong. The PROPS line has these counts, and also how often the written vector was the first hit, which after sealing depends on the graph walk and is not a check.

The exit code is 0 when every check passed, 1 when a check failed (see "Checks" below), and 2 for a wrong option or a wrong combination of options.

Memory, as an estimate that no run has confirmed yet: the harness holds the vectors (n times dimension times 4 bytes, 3.1 GB at the default), the tier holds its own copy of every vector, and a merge builds a new segment while it still holds the old ones. Allow about 10 GB of heap at 1,000,000 vectors of dimension 768 and give the JVM -Xmx14g. The MEMORY lines of a result file give what the run used.

The data

  • Vectors. A Gaussian mixture on the unit sphere: --clusters (100) unit centroids drawn from the seed, and the vector of an id is normalize(centroid + sigma * noise) with --sigma 0.4 (the generator GraphT.Gen of the tests, which GraphTest bench also uses). The cluster of an id and the noise are a function of the seed and the id only, and the Gaussian uses StrictMath, so the data does not depend on the machine.
  • Queries. --queries vectors of the same distribution, with ids that are not in the index (from 2^50 up). They are not inserted.
  • Filter. An id is allowed when a hash of the id and the seed, as a number in [0, 1), is below the share. The allowed sets of the shares are nested (the set of 0.01 is inside the set of 0.1), and the filter does not depend on the vector. A filter that is correlated with the vectors, such as one tenant per cluster, behaves differently and is not measured here.
  • Metric. Cosine. The vectors have unit length, so the exact scan uses the dot product.

The exact scan and recall

The harness computes the exact top k of every query with its own scalar dot product, in one pass over the vectors on all available cores. It does not use a kernel of the library, so a wrong kernel cannot hide behind itself. It does that for the unfiltered query and for every share. Recall@k of a query is the share of the exact ids that the answer contains (the truth is the allowed set when the query has a filter). The SEARCH line has the mean over the queries and the minimum. A tie at the boundary of the top k can swap one id, so recall of exactly 1 is not expected from an exact path: the score of an answer is compared with the exact score instead (maxScoreError).

The first pass over the queries in a cell is the warm-up and measures recall. The next --reps passes are timed, one search at a time on one thread, and give p50, p99, p99.9, mean, maximum and operations per second. A cell with scanFirst=true runs the exact scan of the allowed ids in every segment (the plan of DESIGN.md).

Real data

--data DIR replaces the generated vectors, queries and exact answers with the files of a real embedding set. The set it was written for is the DBpedia entities set with OpenAI embeddings (text-embedding-3-large, 1536 dimensions, 1,000,000 rows, 26 parquet shards), the question of issue #106: does the recall of the tier at 1,000,000 vectors depend on the build parameters as strongly on real embeddings as on the clustered Gaussian data?

Prepare the files

The script scripts/prep_real_dataset.py converts the shards once. It declares its two dependencies (numpy and pyarrow) in a header, so uv run installs them, and it is not part of the Maven build:

uv run --python 3.12 scripts/prep_real_dataset.py SHARDS_DIR DATA_DIR --queries 1000

It reads the shards once, holds 1000 rows out as the query set (drawn at random with --seed, 42 by default), and writes the rest as the index. Then it scans the index in blocks of vectors to find the exact top 10 of every query by the cosine, and rescores the best candidates of each query in float64. It never holds the whole set, and one run needs well under 8 GB of memory (a batch of rows while reading, and a block of vectors with a queries x block score matrix while scanning). The 1,000,000-row set gives an index of 999,000 vectors and 1000 queries. --limit N uses only the first N rows, for a smaller index with its own exact answers (100,000 vectors for a comparison with the 100,000 row of issue #106). --column names the column of embeddings (the default is the one of the DBpedia set), and --truth-k the number of exact answers per query (10).

DATA_DIR holds four files. The loader (RealData.java) checks their sizes against the header, and every vector for a non-finite value and for a length other than 1, so a partial or an unnormalised file stops the run before a measurement is made.

File What it holds
vectors.f32 count vectors of dim float32 values, little endian, row after row. The id of a vector is its row
queries.f32 The held-out queries, the same layout. None of them is a row of vectors.f32
truth.i32 For each query, the truth-k rows of vectors.f32 nearest by the cosine, best first, int32 little endian
meta.properties key=value lines: format (1), dim, count, queries, truth-k, normalized (true), and where the data came from. It is written last, and a directory without it is refused

The data is normalised: the script scales every vector to length 1 (in float64, then stores float32), so the dot product is the cosine and the tier (Metric.COSINE) and JVector (the dot product) score the same thing. The header keeps the range of the lengths before scaling in source-norm-min and source-norm-max, so the file says whether the scaling changed anything. A tie at the boundary of the top 10 can swap an id (duplicate rows do this), so a recall of exactly 1 is not expected, as for generated data.

A Euclidean set in the HDF5 layout of ann-benchmarks (such as sift-128-euclidean.hdf5) is converted by scripts/prep_ann_hdf5.py HDF5 DATA_DIR. It keeps the vectors as they are, writes metric=l2, takes the first test vectors as queries with their neighbors from the file, and checks some of them against its own exact scan. Only PacedWrites reads such a set. The other programs score by the cosine and refuse it.

What the harness does with the files

  • n and dim come from the header. --n or --dim with another value is refused (exit code 2), because the exact answers are for the whole index. --queries is at most the number of queries in the file, and --k at most truth-k.
  • The cells of the unfiltered search use the exact answers of the file. The filtered cells (--shares, on the tier) need the exact answers of each allowed set, and the harness scans for them itself, as for generated data. When it does, it also compares the answers of the file with its own scan of the same queries (the TRUTH-CHECK line) and fails the run if they share fewer than 98 percent of their ids. A run with --shares "" skips the scan, and then the file is the only truth.
  • The concurrent phase is not available (--conc-seconds above 0 is refused, and the default is taken as 0): its writers add vectors from the generator, which would mix generated vectors into a real set.
  • The SEED line says data=file, and the DATASET line has the path and every key of meta.properties. The DATA line has loadSeconds where a generated run has generateSeconds.

Memory, as an estimate that no run has confirmed yet: the harness holds the vectors as float arrays (6.1 GB for 999,000 vectors of dimension 1536), the tier holds its own copy, and a merge builds a new segment while it still holds the old ones. Allow -Xmx24g for the tier at 1,000,000 vectors of dimension 1536. The MEMORY lines say what the run used.

The JVector arm

--engine jvector builds one JVector graph over the same vectors, with the --m and --efc of the run, and answers the same queries at the same beam widths (--ef and --ef-sweep; JVector's rerankK is the beam width). With --shares given, it also runs one filtered cell per share, with the allowed ids passed to the JVector search as its Bits. It prints the BUILD, MEMORY and SEARCH lines with the keys of the tier's lines, and a JVECTOR line with the jar, the SIMD provider it selected, and the parameters it ran with. It works with generated data and with --data, and with --targets and --disk.

With --quant int8 every value of the vectors and of a query is multiplied by one factor, 127 / max|x| over the indexed vectors, rounded and clamped to [-127, 127], and the graph is built and walked with byte by byte dot products. The arm has two search modes, and a SEARCH or MATCHED line says which in mode=: int8 ranks the hits by the byte scores, and int8-rerank walks on the byte scores and scores the ef candidates again in float32, as the SQ8 graph of the tier does. The score of an int8 hit is the byte dot product divided by the square of the factor, so maxScoreError there is the error of the conversion. The graph file of --disk holds the int8 vectors inline and not the float32 vectors.

JVector is a dependency of the harness only. It is io.github.jbellis:jvector in the profile bench of pom.xml, version 4.1.0-rc.1 (one multi-release jar for JDK 21 and later, Apache 2.0, see THIRD_PARTY.md), with the scope runtime. A release candidate is an exception to the rule of the newest release (4.0.2): the int8 vectors need the byte-vector support of 4.1.0, and the pin moves to 4.1.0 when it is released. It is not in the library jar and not in the dependency set of a normal build, and the CI job checks that. The arm itself is src/bench/jvector/java/ai/humem/tiervec/JVectorArm.java, apart from src/bench/java so that the compile command above keeps working without JVector. The harness reaches it by reflection, and --engine tiervec does not need the jars.

mvn -B -ntp -Pbench dependency:copy-dependencies -DoutputDirectory=target/bench/lib -DincludeScope=runtime
javac -d target/bench/classes --add-modules jdk.incubator.vector -cp 'target/bench/classes:target/bench/lib/*' \
  src/bench/jvector/java/ai/humem/tiervec/JVectorArm.java
java -Xmx24g --add-modules jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp 'target/bench/classes:target/bench/lib/*' \
  ai.humem.tiervec.Bench --data DATA_DIR --engine jvector --out results/$(date +%F)-jvector.txt

The first command downloads JVector and its dependencies. The second needs the classes of the harness, so run the compile step of "Run it" before it. On Java 22 and later JVector selects its native SIMD code when the library loads, and the Vector API otherwise. For the comparison with the tier, which uses the Vector API, add -Djvector.vectorization_provider=panama. The JVM line records the arguments, and the JVECTOR line the provider that ran. With --engine jvector, --conc-seconds above 0, --load, --scan-below and --props are refused.

What the two arms share, and what they do not:

Same in both Different
Data The vectors, the dimension, the queries, k, the exact answers, recall by the overlap with them With --quant, the quantization: the tier's SQ8 has a minimum and a step per vector, the int8 arm has one factor for the whole set
Graph efConstruction, the beam width of the search M of JVector is the maximum degree of a node, and the tier allows 2 M links on its base layer, so equal base degrees need a JVector --m of twice the tier's. JVector prunes with alpha 1.2 and neighbor overflow 1.2 (the tier: alpha 1.0) and adds HNSW-style upper layers, so it is one graph. The tier is segments and an exact tail, and a search visits every segment
Build The vectors JVector builds in one parallel pass. The tier adds one by one (--load add, with seals and merges) or builds one segment (--load rebuild). Compare build seconds only between --load rebuild and JVector, with the same --build-threads (JVector's own default is the number of physical cores of the machine, whatever cores the process may use)
Search One search thread, the same warm-up pass and timed passes, the query given as a float[] and converted inside the timed call The tier runs the Vector API kernels. JVector runs the provider named in the JVECTOR line
Score Unit vectors, so the dot product is the cosine JVector's score is (1 + dot) / 2, and the arm converts it back, so maxScoreError checks the arithmetic and the ids only
Memory MEMORY lines after the build (heap and resident memory) The tier copies every vector. With the Vector API provider JVector wraps the arrays of the harness (no second copy of the vectors), and the native provider copies them off the heap. The graphRamBytesMB of the JVECTOR line is JVector's estimate of the graph alone

The result file

One run writes one file, results/<date>-<host-label>.txt, in lines of key=value pairs that start with a tag. It is plain text so that grep reads it. Nothing is written twice: a line is final when it is printed, and a file that does not end with BENCH-END is a run that did not finish.

Tag What it holds
BENCH-RESULT, RUN The format number, the start time and the host label
COMMIT git rev-parse HEAD of the repository at run time, and the number of modified tracked files (0 for a clean tree)
SEED The seed and the data model
CPU, CPUFLAGS, CPUFREQ, RAM The model of the first allowed core and its flags (a hybrid CPU has cores with different flags, so a run pinned to some cores names those), the cores the process may use, the frequency governor, the memory
OS, JDK, JVM, VECTORAPI The operating system, the JDK version and vendor, the JVM arguments, the garbage collectors, and whether the Vector API module and the vector kernels were in use
PARAMS, CONFIG Every option, and the tier configuration
DATA, TRUTH Time to generate the data (or to load the files, with --data) and to compute the exact answers, a checksum of the first vectors, and the smallest exact answer of each group
DATASET, TRUTH-CHECK With --data only: the path and every key of meta.properties, and the overlap of the exact answers of the file with the harness's own scan (when it scanned)
JVECTOR With --engine jvector only: the jar, the SIMD provider JVector selected, its parameters, the seconds to convert the vectors and to build the graph, and its estimate of the graph's memory
BUILD, BUILD-STATS, BUILD-T Seconds to add and until the tier was settled, inserts per second, the tier statistics (seals, merges, segment sizes, write amplification, back pressure), and a progress line each minute
MEMORY Heap in use and resident memory after a garbage collection, and the peak resident memory (also before the build, in a run that uses one of the options of issues #108 and #118)
MEMORY-INDEX In the same runs: the bytes the index needs to search. The tier: bytesHeld. JVector: its estimate of the graph and the size of the vectors of the arm
SEARCH One cell: kind, share, filterScanBelow, recall, latency percentiles, operations per second, malformed answers, garbage collections during the cell (mode= for the int8 arm)
MATCH-SWEEP, MATCH-TIMED, MATCHED With --targets: recall per beam width, the timed widths, and the latency at each target, per search mode
DISK, PROPS With --disk: the files and their bytes. With --props: the counts of the checks of the writes
CONC, CONC-T, CONC-WINDOW The concurrent phase: adds, deletes and searches per second, search latency overall and per window, every error, a progress line per window
CONC-SETTLE, CONC-CHECK, CONC-RECALL The end state: the live count against the expected count, lastError, and recall against an exact scan of the live set
BENCH-SUMMARY, BENCH-FAILURE, BENCH-END OK or FAIL, the list of failed checks, and the end marker

Checks

The run fails (exit code 1) when:

  • an exception reaches the harness or a thread of the concurrent phase;
  • the live count after the build or after the concurrent phase is not the number of vectors that were added and not deleted (a lost or a phantom vector), or lastError() is set;
  • an answer has more than k hits, scores out of order, an id twice, an id outside the data, or an id that the filter does not allow;
  • a search that began after a delete had returned still finds that id (the deleter deletes the ids 0, 1, 2, ... in order, so the searchers know which deletes were done);
  • a recall floor was set (--min-recall, --min-scan-recall) and a cell is below it;
  • with --data, the exact answers of the file and the harness's own scan share fewer than 98 percent of their ids;
  • with --props, one of the checks of the writes fails;
  • with --disk, nothing was written.

Rules for a run that is meant to be read

  1. Pin the process to cores of one kind and run nothing else beside it. Write down the cores: the file records cpusAllowedList. A laptop on battery, with a turbo that varies, or with its low-power cores, is a directional measurement.
  2. Use a JDK that CI tests (Temurin 21 or 25), name it in the file (JDK), and keep the Vector API module on, unless the run is the scalar one on purpose (-Dai.humem.tiervec.scalar=true).
  3. A claim needs the runs that ROADMAP.md asks for, each in a fresh JVM, and a bound that was written down before the first run. One run is a description.
  4. Commit the file with its commit SHA inside, in results/, and say in the table row of the README what it covers.
  5. Do not compare files from different machines or different JDK builds as if only the library changed.
  6. Compare the tier and JVector only from two runs on the same machine and the same JDK build, one after the other, on the same cores and with the same --build-threads, and say which JVector SIMD provider ran. The table in The JVector arm says what the two arms do not have in common.

Successive merges

MergeGenerations, in src/bench, runs many merges of one tier in a row, to compare the two merge modes of Config.withMergeMode (issue #16). It needs a real data set. It draws rows in an order that depends on the seed only and builds the first --base of them with one rebuildFrom. Each of --generations generations then deletes --delete-pct percent of the rows that are live at its start (at most 25, so that no insert merge falls back to a rebuild because of hidden rows), adds --add-pct percent of the base count from unused rows, seals the tail and calls mergeNow(). The worker never seals or merges by itself, and the writes are the same in both modes.

java -Xms6g -Xmx6g -Xlog:gc:file=gc.log:uptimemillis,level,tags --add-modules jdk.incubator.vector -cp target/bench/classes \
  ai.humem.tiervec.MergeGenerations --data DATA_DIR --base 100000 --add-pct 10 --delete-pct 10 --merge-mode insert --queries 1000 --out result.txt

A GEN line per generation has the seconds of the seal and of the merge, the uptime of the JVM around the merge and around the collection forced before and after it (to match the lines of the GC log), the rows the merge built, and recall at --ef against exact search over the live rows. The exact answers are kept up to date with the harness's own scalar dot product, and the TRUTH-CHECK line compares them with a full scan at the end. The SEARCH-FINAL line has p50, p99 and the mean of one search thread after the last generation. The vectors are held outside the heap, so the heap holds the tier, the queries and the exact answers. The run fails when a merge did not take the path of its mode (an insert merge builds the added rows only, a rebuild builds every live row), when a count is wrong, when an answer is malformed or holds a deleted id, or when recall is below --min-recall. The options and their defaults are the method MergeGenerations.defaults().

Paced writes

PacedWrites, in src/bench, writes into one tier at a fixed rate while searches run at a fixed rate, to compare merge policies (issue #4). It reads a real data set, cosine or l2, builds the first --base rows with one rebuildFrom, searches the idle index for --idle-seconds, adds the next --inserts rows at --rate per second, waits until no seal or merge is due, searches the idle index again, and then measures the layout that the policy left against exact answers that it computes itself. The policy is set with --max-segments, --merge-fan, --merge-trigger-ratio, and --tail-limit. The tail is not sealed by age. --split-beam both alternates the full and the split beam during the paced searches and measures both at the end. --sealed true builds all base + inserts rows into one graph with no stream, the reference a policy is compared with.

java -Xmx6g --add-modules jdk.incubator.vector -cp target/bench/classes ai.humem.tiervec.PacedWrites --data DATA_DIR \
  --rate 400 --max-segments 2 --merge-fan 2 --merge-trigger-ratio 0.1 --out result.txt
Line What it holds
STREAM The stream: its seconds and achieved rate, the longest delay of an add, back-pressure waits, seals, merges and merges into the largest segment, and the busy share (the part of the stream during which a seal or a merge ran)
BIG, WINDOW The end of every merge into the largest segment while the writer ran, and the write amplification between the first and the last of them: rows built by merges divided by adds. It is NA with fewer than 5 such merges
LAT Latency of the paced searches by phase (idle before, stream searches during which no task, a seal, or a merge ran, idle after) and by split beam setting
FINAL, SEARCH, MATCHED The layout at the end, recall and latency at --ef, and latency at matched recall (--targets, as in Latency at matched recall). A returned row counts when its exact score is at least the k-th exact score, so a tie counts

The run fails when a count is wrong, the worker failed, an answer is malformed, the tier did not become idle, or recall at --ef is below --min-recall. The options and their defaults are the method PacedWrites.defaults().

The cost of polling

PollCost, in src/bench, compares a search that has a SearchContext with the same search without one (issue #11). The context never expires and does what a host does at each poll: it reads a cancel flag and System.nanoTime() against a deadline. One JVM builds a tier of 20,000 vectors of dimension 128 and times 200 queries in three cells: tail (the exact scan of a tail), walk (the graph walk of one segment) and scan (the exact scan of a segment under a filter that passes one id in ten). Each of 40 rounds times both arms, and the arm that goes first alternates. A cell reports the median over the rounds of the time with the context divided by the time without it. The run fails when the two arms answer differently.

The workflow poll-cost.yml runs it in 10 fresh JVMs on JDK 21 and on JDK 25 and prints the median, the smallest and the largest ratio of the JVMs. It starts by hand, and on a pull request that changes the harness or the workflow. It has no speed bar: a study writes its bound down before the run, as ROADMAP.md asks. The cells compare the two paths of the same build. They do not compare it with a build that has no polling code.

The cost of a row copy

MappedRows, in src/bench, measures what the mapped reader of the vector section costs in time and saves in heap (Mapped vectors, issue #27). On JDK 21 without preview features a distance copies the row from the mapped buffer into a float[] first. The harness uses the reader of the library. It writes two segments of random vectors with SQ8 codes (200,000 of dimension 128, and 50,000 of dimension 768), and one JVM then times these cases:

Case What is timed
distance-random, distance-in-order one dot product per row, in random order and in row order: on the heap array, on the heap array with a row copy first, and on the mapped file with a row copy first
walk-fp32, walk-sq8 a graph search of the same graph with its vectors on the heap and mapped; the SQ8 walk reads fp32 vectors only to rescore its candidates
exact-scan the exact scan of every row, on the heap and mapped

Each of 15 rounds times every arm, and the arm that goes first changes from round to round. A ratio is the time of an arm divided by the time on the heap in the same round, and a JVM reports the median over the rounds. The run fails when the mapped section differs from the loaded vectors or when the two graphs answer differently.

The workflow mapped-rows.yml runs 5 fresh JVMs per segment on JDK 21 and on JDK 25 and prints the median, the smallest, and the largest ratio of the JVMs. It starts by hand, and on a pull request that changes the harness, the reader, or the workflow. It has no speed bar. What a run does not measure: the first read of a file from disk (the file is in the page cache), memory pressure, and more than one thread. The search cases run with both implementations of SealedVectors loaded in one JVM, as in a tier that holds sealed and loaded segments.

The heap of an opened segment is measured in a JVM of its own for each reader: heap FILE HEAP and heap FILE MAPPED count the used heap after full collections, before and after the file is opened, and keep the graph reachable until the second count. To repeat both measurements on one segment:

mkdir -p target/bench/classes
javac -d target/bench/classes --add-modules jdk.incubator.vector $(find src/main/java src/bench/java -name '*.java')
run() { java -Xmx3g --add-modules jdk.incubator.vector -cp target/bench/classes ai.humem.tiervec.MappedRows "$@"; }
run build target/bench/segment.tvs 200000 128
run run target/bench/segment.tvs
run heap target/bench/segment.tvs HEAP
run heap target/bench/segment.tvs MAPPED

A run with the reader of the library

CI run 46011877820, the pull request that added the reader (#156, head ff1f894047), on two shared GitHub runners. The two JDK jobs ran on different CPUs, so the JDKs cannot be compared. The two tables of each job are the output of MappedRows summary.

In these tables a distance on a mapped row was slower in every row, and an fp32 walk was slower on mapped vectors in three of the four rows and faster in one (50,000 of dimension 768 on JDK 21). An earlier run with a mapped reader inside the harness gave 1.13 to 1.37 for the fp32 walk (issue #27). From the two runs I would not promise a factor on other hardware.

Java 21.0.13.1+2-LTS, 8 float lanes. Ratios are the time divided by the time on the heap: median of the JVMs (smallest to largest).

Rows x dim Case JVMs On the heap Heap, row copied first Mapped file, row copied first
200000 x 128 distance-random 5 147.340 ns per distance 1.34 (1.33 to 1.34) 1.37 (1.34 to 1.43)
200000 x 128 distance-in-order 5 30.650 ns per distance 1.28 (1.25 to 1.53) 1.41 (1.29 to 1.79)
200000 x 128 walk-fp32 5 0.562 ms per query not measured 1.08 (1.05 to 1.09)
200000 x 128 walk-sq8 5 0.501 ms per query not measured 1.01 (0.99 to 1.01)
200000 x 128 exact-scan 5 7.894 ms per query not measured 1.10 (1.06 to 1.14)
50000 x 768 distance-random 5 342.450 ns per distance 1.11 (1.10 to 1.12) 1.18 (1.11 to 1.19)
50000 x 768 distance-in-order 5 164.910 ns per distance 1.67 (1.53 to 1.72) 1.96 (1.91 to 1.99)
50000 x 768 walk-fp32 5 1.217 ms per query not measured 0.92 (0.84 to 0.93)
50000 x 768 walk-sq8 5 0.928 ms per query not measured 0.99 (0.98 to 1.01)
50000 x 768 exact-scan 5 9.291 ms per query not measured 1.46 (1.41 to 1.57)

Heap that stays used after the file is opened, one JVM for each reader, in MiB (1,048,576 bytes).

Rows x dim Vector section Used heap, HEAP Used heap, MAPPED bytesHeld, HEAP bytesHeld, MAPPED Mapped, MAPPED
200000 x 128 97.7 153.8 55.8 149.7 52.1 97.7
50000 x 768 146.5 194.2 46.3 190.0 43.5 146.5

Runner: AMD EPYC 7763 64-Core Processor, 4 processors.

Java 25.0.5+8-LTS, 16 float lanes. Ratios are the time divided by the time on the heap: median of the JVMs (smallest to largest).

Rows x dim Case JVMs On the heap Heap, row copied first Mapped file, row copied first
200000 x 128 distance-random 5 103.660 ns per distance 1.14 (1.11 to 1.14) 1.14 (1.12 to 1.26)
200000 x 128 distance-in-order 5 19.990 ns per distance 1.57 (1.54 to 2.01) 1.60 (1.57 to 2.08)
200000 x 128 walk-fp32 5 0.456 ms per query not measured 1.40 (1.36 to 1.41)
200000 x 128 walk-sq8 5 0.390 ms per query not measured 1.03 (1.02 to 1.08)
200000 x 128 exact-scan 5 5.118 ms per query not measured 1.54 (1.45 to 1.59)
50000 x 768 distance-random 5 295.790 ns per distance 1.27 (1.26 to 1.27) 1.21 (1.21 to 1.22)
50000 x 768 distance-in-order 5 95.430 ns per distance 1.34 (1.25 to 1.56) 1.43 (1.38 to 1.66)
50000 x 768 walk-fp32 5 1.063 ms per query not measured 1.20 (1.15 to 1.21)
50000 x 768 walk-sq8 5 0.606 ms per query not measured 1.01 (1.00 to 1.02)
50000 x 768 exact-scan 5 4.712 ms per query not measured 1.37 (1.31 to 1.57)

Heap that stays used after the file is opened, one JVM for each reader, in MiB (1,048,576 bytes).

Rows x dim Vector section Used heap, HEAP Used heap, MAPPED bytesHeld, HEAP bytesHeld, MAPPED Mapped, MAPPED
200000 x 128 97.7 153.7 55.8 149.7 52.1 97.7
50000 x 768 146.5 194.2 46.3 190.0 43.5 146.5

Runner: AMD EPYC 9V74 80-Core Processor, 4 processors.

The CI smoke

The job bench smoke (JDK 21) and (JDK 25) compiles the harness with the library and runs it at n = 10,000 and dimension 768, with 100 queries, one extra beam width (32), shares 0.1 and 0.01, and 15 seconds of the concurrent phase. It is not a required check, and it runs beside the fast tests. It proves that the harness runs, that its answers agree with its own exact scan, and that the checks above hold on a small tier. It prints timings and has no speed bar: the runner is shared, so a timing is only a ratio inside one run.

The recall floors of the smoke are 0.90 for the unfiltered and the walk cells and 0.99 for the cells that scan first. In the first runs (CI run 43133522549, JDK 21 and 25) recall was 1.0000 unfiltered, 0.997 to 1.0000 for the filtered walk and 1.0000 for every scan-first cell, and a run took 21 to 23 seconds (the job about 30 seconds). The floors leave room for a different structure of the segments from one run to the next, and they are far above what a broken index gives: a tier that returned only its tail would find at most the 20 percent of the data that the tail holds, and the scan-first path is exact apart from a swapped tie at the boundary of the top k. A control step of the job runs the harness with a floor that cannot be met (recall of at least 1.5) and requires exit code 1 and a BENCH-FAILURE line, so the failure path is not a path that never runs.

The same job also runs the two paths of issue #108 on a small data set that it generates (not committed). It writes 5,100 rows of dimension 64 as parquet files in the layout of the DBpedia shards (.github/scripts/make-smoke-parquet.py), converts them with scripts/prep_real_dataset.py (5,000 vectors, 100 held-out queries, vector lengths that the script has to scale), fetches JVector with the profile bench, compiles the arm, and runs the tier and then JVector on the files with --data, with a recall floor of 0.85. It checks that both runs end with status=OK, that they ran the same unfiltered cells and the same vectors (the checksum of the DATA line), that the tier's run compared the exact answers of the file with its own scan, and that the JVECTOR line names the jar. Controls run both paths with a floor that cannot be met and require exit code 1, and they require exit code 2 for --n that does not match the file, for --engine jvector with a concurrent phase, and for --engine jvector without the JVector jars. A last check lists the default runtime dependencies of the library (mvn dependency:list) and fails when JVector is among them.

It also runs MergeGenerations in both merge modes on the same files, and PacedWrites, with its sealed reference, on those files and on a small Euclidean set that it generates (.github/scripts/make-smoke-hdf5.py, converted by scripts/prep_ann_hdf5.py), each with controls.

AgentMemorySelfCheck runs the tests of the agent-memory benchmark: the runbook file and its workload, the exact answers on a small case with deletes and replacements, every violation counter, and replays with arms that are wrong on purpose. Then AgentMemory replays runbooks of 3,000 rows and of 50 times 20 rows into the exact arm, three settings of the tier, and the live graph at alpha 1.0 and 1.2. The step requires no failing violation, recall of at least 0.90 at every checkpoint, recall 1 for the exact arm, a batch seen in part on the arms without atomic batches and never on the tier, and exit codes 1 and 2 for a floor that cannot be met and for a wrong variant. A last step compiles the copy of the library that counts distance computations (scripts/instrument_distances.py) and runs the screen preset on its two smallest shapes. It requires one distance per live row for the exact arm, the same result files from two runs of one seed apart from the heap, and exit code 2 for a screen on a build that does not count.

The options of issue #118 run on the same files: the tier rebuilt in float32 and in SQ8 (with --targets, --disk and --props), and JVector in float32 and in int8. The job requires status=OK, a MATCHED line for the lower target, a non-empty index on disk, no written vector missed by the next search, both search modes of the int8 arm, and exit code 2 for --quant sq8 with JVector. One more int8 run forces the Vector API provider and checks the provider name.