Skip to content

⚡ Optimize FileList#first_seen_at to eliminate allocations#622

Merged
danmayer merged 1 commit intomainfrom
perf-file-list-first-seen-at-3731001549367096294
Feb 10, 2026
Merged

⚡ Optimize FileList#first_seen_at to eliminate allocations#622
danmayer merged 1 commit intomainfrom
perf-file-list-first-seen-at-3731001549367096294

Conversation

@danmayer
Copy link
Owner

💡 What: Replaced the filter_map implementation in Coverband::Utils::FileList#first_seen_at with an imperative each loop to find the minimum first_updated_at timestamp.

🎯 Why: The previous implementation (and the one suggested in the task description) allocated intermediate arrays. Even filter_map, while efficient, creates a new array. By using each and tracking the minimum value manually, we eliminate these allocations entirely.

📊 Measured Improvement:
Benchmark results for 10,000 files:

  • Original (map + reject): ~169 KB allocated
  • Previous (filter_map): ~89 KB allocated
  • New (each): 0 bytes allocated

CPU performance is comparable (slightly faster in some runs, but within margin of error). This change significantly reduces memory pressure for large file lists.


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

Replaced the `filter_map` implementation with an `each`-based loop to calculate the minimum `first_updated_at` timestamp. This eliminates intermediate array allocations (reducing memory usage from ~89KB to 0 bytes for 10k items) while maintaining comparable CPU performance.

Added a benchmark script `test/benchmarks/benchmark_file_list.rb` to verify the improvement.

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.

@danmayer danmayer merged commit 8ae1212 into main Feb 10, 2026
97 checks passed
@danmayer danmayer deleted the perf-file-list-first-seen-at-3731001549367096294 branch February 10, 2026 06:59
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