Skip to content

GH-1471: Add embedding speed benchmarks - #1472

Draft
krickert wants to merge 1 commit into
feat/GH-1391-embed-batch-capfrom
feat/embeddings-timings-tests
Draft

krickert wants to merge 1 commit into
feat/GH-1391-embed-batch-capfrom
feat/embeddings-timings-tests

Conversation

@krickert

@krickert krickert commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1471

Allocation per call (gc.alloc.rate.norm, all-MiniLM-L6-v2, JDK 21, RTX 4080 SUPER, 1 fork x 5 iterations), before and after the inputs and outputs moved to direct buffers:

Benchmark callSize GPU before GPU after CPU before CPU after
embedAll 1 50 KB 21 KB 54 KB 17 KB
embedAll 8 384 KB 136 KB 410 KB 161 KB
embedAll 32 2037 KB 767 KB 2039 KB 769 KB
embedAll 128 7904 KB 2424 KB 7908 KB 2862 KB
embedEach 1 53 KB 17 KB 53 KB 21 KB
embedEach 8 411 KB 162 KB 410 KB 162 KB
embedEach 32 1930 KB 656 KB 2062 KB 787 KB
embedEach 128 7591 KB 2597 KB 8121 KB 3035 KB

Average time per call on the GPU did not change (it is bound by inference). embedAll at callSize 128 takes 23.8 ms against 67.4 ms for embedEach. CPU times vary by more than 50 percent between iterations with ONNX Runtime's default thread settings, so they are not listed.

@krickert

krickert commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@rzo1 I needed to make this to test the embeddings. I know before you were talking about expanding something like this/unifying it.. so I'm just keeping as a draft now. I'll add more details to the ticket a lil later

@krickert krickert closed this Oct 11, 2026
@krickert krickert reopened this Oct 11, 2026
@krickert
krickert force-pushed the feat/embeddings-timings-tests branch from b26898c to 5bcfe05 Compare October 11, 2026 12:20
@krickert
krickert changed the base branch from main to feat/GH-1391-embed-batch-cap October 11, 2026 15:05
@krickert
krickert force-pushed the feat/GH-1391-embed-batch-cap branch from dc68fd7 to f2a2206 Compare October 11, 2026 22:39
@krickert
krickert force-pushed the feat/embeddings-timings-tests branch from 5bcfe05 to 926e192 Compare October 11, 2026 22:40
@krickert
krickert force-pushed the feat/GH-1391-embed-batch-cap branch from f2a2206 to e540ab2 Compare October 12, 2026 01:20
…rs off the heap

SentenceVectorsDLBenchmark times embed per text and embedAll for calls of
1 to 128 texts of mixed length, on the CPU or CUDA device 0. The
opennlp-dl module gets the same jmh profile as opennlp-runtime, and
BENCHMARKS.md documents how to run it and the allocation numbers.

Each inference copied the inputs from long arrays into heap buffers,
which ONNX Runtime copied again into direct memory, and fetched the
output through getValue(), which builds one float array per token.
The inputs are now written into direct buffers, and ONNX Runtime writes
the output into a direct buffer that pooling uses in place. Only the
requested output is computed.

SentenceVectorsDLBenchmark with -prof gc on all-MiniLM-L6-v2: heap
allocation per call is 58 to 69 percent lower on CPU and GPU, for
example embedAll of 128 texts on the GPU drops from 7904 KB to 2424 KB.
Time per call on the GPU is unchanged.

Signed-off-by: Kristian Rickert <kristian@apache.org>
Co-authored-by: Claude Code 2.1.296 (Opus 5.5)
@krickert
krickert force-pushed the feat/embeddings-timings-tests branch from 926e192 to 7ecbba4 Compare October 12, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create embeddings benchmark for ONNX

1 participant