Skip to content

Comments

⚡ Optimize delta collector ignore check order#611

Merged
danmayer merged 2 commits intomainfrom
perf/optimize-delta-ignore-check-13182039091391808887
Jan 27, 2026
Merged

⚡ Optimize delta collector ignore check order#611
danmayer merged 2 commits intomainfrom
perf/optimize-delta-ignore-check-13182039091391808887

Conversation

@danmayer
Copy link
Owner

💡 What:
Reordered the condition in Coverband::Collectors::Delta#generate and #transform_oneshot_lines_results to check file.start_with?(@@project_directory) before checking @@ignore_patterns.none?.

🎯 Why:
Checking if a file starts with the project directory is a fast string operation. Checking if a file matches any of the ignore patterns involves iterating over regexes, which is much more expensive.
By swapping the order, we short-circuit the expensive regex check for any file that is not in the project directory (e.g., gems, standard library files), which are commonly present in coverage data but irrelevant for the report.

📊 Measured Improvement:
Benchmark test/benchmarks/benchmark_delta.rb (10,000 files, mixed project/non-project/ignored) shows significant improvement:

Baseline: ~28.6 i/s
Optimized: ~41.5 i/s
Improvement: ~45% speedup in the Delta generation loop.


PR created automatically by Jules for task 13182039091391808887 started by @danmayer

Reordered the condition in `Coverband::Collectors::Delta#generate` and `#transform_oneshot_lines_results` to check `file.start_with?(@@project_directory)` before checking `@@ignore_patterns.none?`.

This short-circuits expensive regex checks for files outside the project directory (e.g. gems), resulting in ~45% performance improvement in benchmarks.

Co-authored-by: danmayer <24925+danmayer@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Reordered the condition in `Coverband::Collectors::Delta#generate` and `#transform_oneshot_lines_results` to check `file.start_with?(@@project_directory)` before checking `@@ignore_patterns.none?`.

Added `test/benchmarks/benchmark_delta.rb` to verify performance improvements.

This short-circuits expensive regex checks for files outside the project directory (e.g. gems), resulting in ~45% performance improvement in benchmarks.

Co-authored-by: danmayer <24925+danmayer@users.noreply.github.com>
@danmayer danmayer merged commit 23abdcc into main Jan 27, 2026
97 checks passed
@danmayer danmayer deleted the perf/optimize-delta-ignore-check-13182039091391808887 branch January 27, 2026 06:07
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