Caching efficiency experiment for AutoIntent 0.3.1 - #37
Merged
Conversation
Benchmarks the file-based embeddings and LLM structured-output caches: warm-read speedup, key/get_hash overhead, reuse under realistic access patterns, storage footprint, cross-model collisions, and non-atomic-write robustness. Includes DESIGN.md (methodology) and REPORT.md (findings + propose-only solutions from small fixes to a SQLite/LMDB rewrite). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…in #340) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NLnHtppRLp6PALVTgyLfoH
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.
Summary
A new experiment under
experiments/caching-efficiency/that measures the efficiency of AutoIntent 0.3.1's two file-based caches (embeddings.npycache and the LLM structured-output cache) and proposes improvements. uv-managed project;ruff+mypy --strictpass clean.Reviewable artifacts (markdown):
experiments/caching-efficiency/REPORT.md— findings, root causes, and propose-only solutions (small fixes → SQLite/LMDB rewrite).experiments/caching-efficiency/DESIGN.md— how the cache works + evaluation methodology.Verdict
The caches are excellent for their designed workload (re-embedding the same fixed inputs across many trials): warm reads are 1000–4400× faster than recompute with negligible key overhead. Outside exact-input-match they degrade, and there are four real bugs.
Efficiency limits
get_hash()re-pickles all params every call (~57–171 ms, not memoized).Bugs found
"main"enables cross-model collisions when HF Hub is unreachable.__init__preload loads nothing (is_file()filter vs directory entries).Upstream status (as of AutoIntent v0.4.0, August 2026)
The findings above are against 0.3.1. Since this experiment was conducted, three of the four bugs have been fixed upstream (verified on the
devbranch, v0.4.0):model_nameandbase_url.get_hash()always hashes the model name; offline path reads the SHA from the local HF cache ref file.is_dir().REPORT.mdcarries the same status table at the top, so post-merge readers won't mistake the 0.3.1 bug list for the current state of AutoIntent.How it was run
No OpenAI calls or keys: the LLM path is simulated and embeddings use a local sentence-transformers model. Cache IO is redirected to a temp dir (the real user cache is untouched). Raw outputs in
results/*.{csv,json}+ 3 PNGs.Test plan
REPORT.md(verdict + §4 bugs + §6 proposals) andDESIGN.md.uv sync && uv run python run_all.pyreproducesresults/numbers.uv run ruff check . && uv run mypy .pass clean.struct_collision) and non-atomic poisoning (concurrency) findings.🤖 Generated with Claude Code