Repository navigation
feat(plugin-embeddings): batch embed() calls through a SQLite vector store - #1227
Merged
Merged
Conversation
…store
Red: the worker answers {"calls": [...]} with one encode per model and
results in request order, the cache is one SQLite database per model with
whole-batch lookups, the fragment declares batch, and the speed-of-light
bar is no longer xfail.
…store
The worker answers {"calls": [...]} with one model.encode() per model and
results in request order; {"call"} keeps working. The per-value cachetta
files give way to one SQLite database per model, looked up per batch in one
query and written in one transaction. The packaged fragment sets
batch = 4096, measured as the fastest of 256..65536 on a 65536-abstract
corpus (0.83x a bare batch encode, startup excluded, down from 4.5x).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1204
Plugin half of #1204: the worker answers dirsql's batched
{"calls": [...]}requests with onemodel.encode()per model, the per-value cachetta files give way to one SQLite database per model (whole batch looked up in one query, misses written in one transaction), the packaged fragment setsbatch = 4096, and the embeddings speed-of-light test loses itsxfail.Measurements
Harness:
tests/e2e/speed_of_light_test.py(best of 3, startup = mean of 10--helpruns, corpus doubled until the bare batch encode takes a second). Bar: dirsql wall minus startup <= 1.1x native.Before (
origin/main,--runxfail, corpus grew to 32768 abstracts):Batch sweep on this branch (corpus grew to 65536 abstracts, native 1.254s, startup 0.049s; a second sweep with other agents loading the box was noisier but 4096 stayed at 0.84x):
batch = 4096is the smallest value that clears the bar with margin and is the fastest measured. Above model2vec'smultiprocessing_threshold(10,000 texts) encode forks joblib workers, which costs more than it saves on this corpus, so bigger batches lose. The committed test passes:tests/e2e/speed_of_light_test.py1 passed.Local note: the plugin venv had PyPI dirsql 0.4.56 (the user-level uv
exclude-newer = "3 days"hides 0.4.60+, which carrybatch); measurements ran against 0.4.61 pulled with--exclude-newer-package. CI installs from PyPI without that setting.Manual run
Second run of the same query: identical rows, all served from the two databases (3 rows in the default model's, 1 in potion-base-8M's).
E2E Verification
packages/pythonuntouched)packages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python): N/Apackages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts): N/Aplugins/dirsql-plugin-embeddings/e2e-attestations/claude-1204-embed-plugin-batch.jsonreceipt writtencd plugins/dirsql-plugin-embeddingsthenuvx testing-conventions e2e attest 'uv run --with-editable ../../packages/python python -m pytest tests/e2e/ -x -q'uv run --with-editable ../../packages/python python -m pytest tests -q -x(unit, integration, e2e)just preflightChangelog / Migrations
plugins/dirsql-plugin-embeddings/changelog.d/2026-10-02-batched-embed-sqlite-cache.mdplugins/dirsql-plugin-embeddings/migrations.d/2026-10-02-batched-embed-sqlite-cache.md(on-disk cache format changes; old per-value files are ignored, never read, wipe the directory to reclaim space; the fragment'sbatchneeds dirsql >= 0.4.60)