bench: Go benchmarks for store, code index, survey, grammar, parse, memory - #45
Open
jmylchreest wants to merge 2 commits into
Open
bench: Go benchmarks for store, code index, survey, grammar, parse, memory#45jmylchreest wants to merge 2 commits into
jmylchreest wants to merge 2 commits into
Conversation
…e, memory paths New benchmark files (6) measuring the hot paths across aide: - pkg/store: bolt+bleve memory commit/retrieval, code index batch/symbol/ search/clear (per-op and batched) - pkg/survey: churn, entrypoints, call graph, freshness against a scratch repo - pkg/grammar: full project scan (ScanProject/ScanDetail), language normalise - pkg/code: tokenize vs parse cost for Go + TypeScript - pkg/memory: score memory All benchmarks construct their own stores in b.TempDir() and use only in-memory synthetic fixtures (mock grapher/searcher reused from existing tests) — zero real-data access, zero network. No existing files modified. Measurement pass (devbox, -benchmem -count=3) highlights: - write paths are fsync-bound (~9-25ms/commit); IndexFileBatch is ~27x cheaper per record than AddSymbol, confirming the batching rationale - retrieval is index-bound: symbol search 2.7ms/3k corpus, ref lookup ~10us - parsing ~0.65ms/file is the scan CPU hotspot; storage still gates indexing - language detection ~97ns alloc-free; memory scoring ~330ns alloc-free Co-authored-by: Hermes <jmylchreest+hermes@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… rotation AddSymbol and BoltStoreAddMemories previously wrote N fresh records into one growing store, so b.N iterations measured 'add to an ever-larger index' (fragmented bleve segments) rather than steady-state commit cost. Profile confirmed scorch.mergerLoop absorbing ~72% of allocations purely from this. Rotate a fixed pool (512 symbols / 256 memories) and give each element a stable deterministic ID. AddSymbolTx/AddMemory only mint a ULID when the ID is empty, so a non-empty ID makes each op overwrite the same bbolt key and bleve doc: the index stays at a stable size and per-op cost stops growing. Verified: ns/op varies only +-15% across a 512x span of b.N, and is flat even after 2 full pool laps (AddSymbol 25.9M ns/op at 1024x, AddMemories 33.0M ns/op at 512x) — had ULIDs still been minted, a 2x record count would show growing cost. Steady-state upsert achieved. Co-authored-by: Hermes <jmylchreest+hermes@gmail.com>
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.
Benchmark suite for the store / code-index / survey hot paths
Adds 18 benchmarks across 6 packages, measuring the scan / commit / retrieval paths. All construct their own stores in
b.TempDir()with in-memory synthetic fixtures (mock CodeGrapher/CodeSearcher reused from existing tests) — zero real-data access, zero network. No existing files modified.Files (all new)
pkg/store/store_bench_test.gopkg/store/code_bench_test.gopkg/survey/survey_bench_test.gopkg/grammar/grammar_bench_test.gopkg/code/code_bench_test.gopkg/memory/memory_bench_test.goKey findings (devbox,
-benchmem -count=3)IndexFileBatchis ~27× cheaper per record thanAddSymbol(~0.7 ms vs ~19 ms per symbol) — empirically validates the batching design.GetFileSymbols~250 µs (JSON decode dominated).Verification
go vet— clean, exit 0-benchtime=1x -count=1) — all 18 benchmarks PASSb.TempDir()(local /tmp, not NFS)Co-authored-by: Hermes jmylchreest+hermes@gmail.com