Skip to content

perf: keep hot paths within frame budget - #54

Merged
baanish merged 4 commits into
masterfrom
codex/perf-frame-budget
Jul 23, 2026
Merged

perf: keep hot paths within frame budget#54
baanish merged 4 commits into
masterfrom
codex/perf-frame-budget

Conversation

@baanish

@baanish baanish commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • give best-effort command telemetry a 5 ms SQLite busy timeout, while explicit stats opens keep the existing 3 second policy
  • prune scanner traversal below hidden directories and exact node_modules directories
  • add real-process CLI benchmarks plus hidden-tree and dependency-tree scan benchmarks
  • enable thin LTO, one release codegen unit, and symbol stripping

Preserved behavior

  • project detection still checks .git and all six markers: Cargo.toml, package.json, go.mod, pyproject.toml, requirements.txt, and Makefile
  • a missing, empty, or corrupt project cache still rescans synchronously
  • the stats schema, WAL setup, and explicit stats command timeout are unchanged
  • panic behavior is unchanged

Local measurements

  • common process operations: approximately 3.9–6.7 ms in Criterion quick-mode samples
  • hidden-tree pruning fixture (1,000 entries): approximately 3.85–3.89 ms
  • node_modules pruning fixture (1,000 packages): approximately 3.50–3.62 ms
  • telemetry under a held SQLite write lock: successful command completion in approximately 20 ms instead of waiting near the old 3 second timeout
  • release binary: 8,036,992 bytes → 6,073,904 bytes (24.4% smaller)

The broad synthetic scan remains proportional to real filesystem work: the 300-project nested fixture measured approximately 35.5–36.5 ms.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --locked -- -D warnings
  • cargo test --locked (121 tests passed)
  • cargo build --release --locked
  • cargo bench --bench cli_bench --no-run
  • cargo bench --bench scan_bench --no-run
  • cargo bench --bench go_bench --no-run
  • quick-mode smoke runs for all three benchmark targets
  • manual SQLite lock-contention smoke test
  • independent review: approved with no findings

Summary by CodeRabbit

  • Performance

    • Improved project scanning by skipping hidden directories and node_modules, reducing unnecessary work on large codebases.
    • Optimized release builds for faster, smaller command-line binaries.
    • Statistics recording now fails quickly when the database is busy, minimizing disruption to normal commands.
  • Bug Fixes

    • Corrected detection of npm test scripts so they run with the appropriate command.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@baanish, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d5f2d907-dedf-47ba-be65-6990198ef4b6

📥 Commits

Reviewing files that changed from the base of the PR and between 78ab930 and 13121f0.

📒 Files selected for processing (2)
  • Cargo.toml
  • src/main.rs
📝 Walkthrough

Walkthrough

The PR adds telemetry-specific SQLite timeouts, prunes scanner traversal, introduces isolated CLI and scan benchmarks, tunes release builds, and updates environment handling. It also simplifies npm test command selection and synchronizes an environment-dependent test.

Changes

Performance and benchmark improvements

Layer / File(s) Summary
Telemetry database timeout
src/stats_db.rs, src/main.rs, docs/superpowers/plans/...
Telemetry database writes use a 5ms busy timeout while normal opens retain a 3s timeout; lock-contention behavior is tested.
Scanner traversal pruning
src/scanner.rs, docs/superpowers/plans/...
Traversal skips hidden directories and node_modules, with tests for nested projects and non-UTF8 names.
Isolated benchmark fixtures and execution
benches/common/mod.rs, benches/go_bench.rs, benches/scan_bench.rs, docs/superpowers/plans/...
Benchmark configuration is loaded without ambient environment state, and QR_CONFIG_DIR is scoped during execution.
CLI benchmark target
Cargo.toml, benches/cli_bench.rs, docs/superpowers/plans/...
Adds executable benchmarks for config lookup, project matching, failures, and Unix command execution.
Release build configuration
Cargo.toml, docs/superpowers/plans/...
Release builds enable thin LTO, one codegen unit, and symbol stripping.

Behavior and test corrections

Layer / File(s) Summary
Command qualification and environment isolation
src/project_profile.rs, src/ai/client.rs
The npm test script maps directly to npm test, and an environment-dependent test uses the shared lock.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant StatsDb
  participant SQLite
  CLI->>StatsDb: open_for_telemetry(stats path)
  StatsDb->>SQLite: configure 5ms busy timeout
  CLI->>StatsDb: record(stats)
  StatsDb->>SQLite: write telemetry
Loading
sequenceDiagram
  participant Scanner
  participant WalkDir
  participant Predicate
  Scanner->>WalkDir: start traversal
  WalkDir->>Predicate: inspect directory entry
  Predicate-->>WalkDir: allow or prune descent
  WalkDir-->>Scanner: return allowed entries
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the PR’s performance-focused changes to hot paths and benchmarked runtime behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/perf-frame-budget

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@baanish
baanish marked this pull request as ready for review July 10, 2026 19:18
@baanish

baanish commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@kilo-code-bot

kilo-code-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (11 files)
  • Cargo.toml
  • benches/cli_bench.rs
  • benches/common/mod.rs
  • benches/go_bench.rs
  • benches/scan_bench.rs
  • docs/superpowers/plans/2026-07-10-frame-budget-performance.md
  • src/ai/client.rs
  • src/main.rs
  • src/project_profile.rs
  • src/scanner.rs
  • src/stats_db.rs

Reviewed by gpt-5.6-terra · Input: 62.3K · Output: 4.7K · Cached: 340.6K

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 78ab930d60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@baanish
baanish merged commit b75ed73 into master Jul 23, 2026
4 of 5 checks passed
@baanish
baanish deleted the codex/perf-frame-budget branch July 23, 2026 21:26
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