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

@ajianaz ajianaz commented Jul 2, 2026

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

# File Issue Fix
#41 src/engine/rules/matching.rs Regex recompiled per line Pre-compile regex once via ensure_compiled()
#5 src/mcp/tools.rs Per-file DB queries in nested loops Batch all symbols in single IN query
#13 src/main.rs Repeated graph lookups in Affected cmd Single batch query for all changed files
#14 src/main.rs Prepared statement in inner loop Prepare once before loop
#59 src/engine/secrets_scanner.rs No early cutoff after max_findings Break out of all loops when cap reached
#70 src/engine/context/extraction.rs Symbol cap only breaks inner loop Break all three nested loops
#67 src/engine/context/resolver.rs Repeated file reads from disk HashMap<PathBuf, String> cache
#3 src/mcp/tools.rs New Tokio runtime per MCP call Static LazyLock<Runtime>
#22 src/index/extract.rs Regex per detect_function_entry call static LazyLock<Regex> per language
#24 src/index/mod.rs Per-file transaction in prune_deleted Single transaction for all deletes

Testing

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

Refs #335

ajianaz and 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 develop Jul 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
@ajianaz ajianaz mentioned this pull request Jul 16, 2026
Sign up for free to 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