Skip to content

perf: resolve scan/review pipeline performance bottlenecks (P2) - #338

Merged
ajianaz merged 3 commits into
developfrom
fix/p2-performance-bottlenecks
Jul 16, 2026
Merged

perf: resolve scan/review pipeline performance bottlenecks (P2)#338
ajianaz merged 3 commits into
developfrom
fix/p2-performance-bottlenecks

Conversation

@ajianaz

Copy link
Copy Markdown
Collaborator

Summary

Fixes 10 performance bottlenecks across the scan/review pipeline. All are "repeated work in loops" patterns — the fix is always the same: do it once outside the loop.

Fixes

#FileIssueFix
#41src/engine/rules/matching.rsRegex recompiled per linePre-compile regex once via ensure_compiled()
#5src/mcp/tools.rsPer-file DB queries in nested loopsBatch all symbols in single IN query
#13src/main.rsRepeated graph lookups in Affected cmdSingle batch query for all changed files
#14src/main.rsPrepared statement in inner loopPrepare once before loop
#59src/engine/secrets_scanner.rsNo early cutoff after max_findingsBreak out of all loops when cap reached
#70src/engine/context/extraction.rsSymbol cap only breaks inner loopBreak all three nested loops
#67src/engine/context/resolver.rsRepeated file reads from diskHashMap<PathBuf, String> cache
#3src/mcp/tools.rsNew Tokio runtime per MCP callStatic LazyLock<Runtime>
#22src/index/extract.rsRegex per detect_function_entry callstatic LazyLock<Regex> per language
#24src/index/mod.rsPer-file transaction in prune_deletedSingle transaction for all deletes

Testing

  • ✅ All 609 tests pass (cargo test)
  • ✅ Clippy clean (cargo clippy)
  • ✅ Formatted (cargo fmt)

Refs #335

ajianazand others added 3 commits July 2, 2026 12:06
Fix 10 performance issues — all 'repeated work in loops' patterns:
#41 - Pre-compile regex patterns once per rule instead of per line
#5 - Batch DB queries in handle_find_affected_tests (single IN clause)
#13 - Batch symbol fetch for Affected command (single query)
#14 - Prepare SQL statement once outside test-pattern loop
#59 - Early cutoff in secrets scanner when max_findings reached
#70 - Break out of all loops when symbol cap hit per file
#67 - Cache file reads during sibling search in resolver
#3 - Reuse single Tokio runtime for MCP tool calls (static LazyLock)
#22 - Static LazyLock regexes in detect_function_entry
#24 - Single transaction for prune_deleted instead of per-file
Refs #335
- clippy: remove redundant borrow in format! arg (llm.rs:456 &user_prompt)
- security: bump anyhow 1.0.102 -> 1.0.103 (RUSTSEC-2026-0190, downcast_mut unsoundness)
- security: bump crossbeam-epoch 0.9.18 -> 0.9.20 (RUSTSEC-2026-0204, fmt::Pointer null deref)
Refs #335
@ajianaz
ajianaz merged commit 1ee0f27 into developJul 16, 2026
10 checks passed
ajianaz added a commit that referenced this pull request Jul 16, 2026
…eyword (#341)
A merged PR that references issues via "Refs #N" (not "Closes #N") has no
closingIssuesReferences — a legitimate non-error outcome. Previously the
script could abort with exit 1 under 'set -e' when get_item_id() hit an
unexpected GraphQL response shape (e.g. node: null), surfacing as a red
'sync' check on otherwise-green PRs (e.g. PR #338 merge).
- Make get_item_id() and the LINKED query python defensive against null/unexpected shapes
- Guard the empty-LINKED branch call sites with '|| true' so a missing board item never aborts the job
Sign up for freeto 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.

1 participant

@ajianaz