perf(inmemory): index-based deep run search + benchmark#82
Merged
Conversation
InMemoryFlowRunStore deep search (deepSearch:true) matched step content by scanning the global _steps dictionary once per candidate run, filtering by RunId inside the scan — O(runs x total_steps), quadratic in run history. It now enumerates each run's own steps via the existing _stepKeysByRun index and direct-looks-up _steps — O(runs x steps_in_run), mirroring GetRunDetailAsync. Behaviour is unchanged (same matches); only the scan strategy differs. Benchmark (tests/benchmarks/.../RunSearchBenchmarks.cs, in-process, MemoryDiagnoser): at 10,000 runs deep search drops from ~24,966 ms / 4.6 GB to ~24 ms / 2.6 MB (~1,040x faster, ~1,800x less alloc); deep 1k->10k scaling 274x -> ~16x (linear). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.27.0 is already published (immutable); the in-memory deep-search index fix ships as a patch. Bumps VersionPrefix to 1.27.1 and promotes the CHANGELOG Performance entry into the 1.27.1 section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…issed-where) The index-based deep-search loop tripped cs/linq/missed-where on the diff. Rewrite the per-run step scan as stepKeys.Keys.Any(...) — same O(steps_in_run) index lookup, explicit filter the analyzer accepts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Summary
Follow-up to #81. A new BenchmarkDotNet case (
RunSearchBenchmarks) revealed that in-memory deep run search was quadratic:InMemoryFlowRunStore.MatchesRunSearch(deep branch) scanned the global_stepsdictionary once per candidate run, filtering byRunIdinside the scan — O(runs × total_steps)._stepKeysByRunindex + direct_stepslookups — O(runs × steps_in_run), mirroringGetRunDetailAsync. Behaviour is identical (same matches); only the scan strategy changed.tests/benchmarks/.../RunSearchBenchmarks.cs(in-process,[MemoryDiagnoser]) + results doc.Measured (InMemoryFlowRunStore,
GetRunsPageAsync(search, take:20))Deep 1k→10k scaling: 274× (quadratic) → ~16× (linear).
Test plan
dotnet build0/0 (net8/9/10)🤖 Generated with Claude Code