Skip to content

perf: ⚡ Bolt: avoid allocating joined strings in sort_by#106

Open
damacus wants to merge 2 commits intomainfrom
bolt/avoid-string-join-sorting-1502315767318017684
Open

perf: ⚡ Bolt: avoid allocating joined strings in sort_by#106
damacus wants to merge 2 commits intomainfrom
bolt/avoid-string-join-sorting-1502315767318017684

Conversation

@damacus
Copy link
Copy Markdown
Owner

@damacus damacus commented Apr 1, 2026

💡 What: Removed .join(", ") calls inside sort_by for comparing runner tags and replaced it with a direct Vec lexicographical .cmp().
🎯 Why: Creating new, dynamically allocated Strings for every comparison step within a generic sorting loop creates hidden O(N log N) heap allocations. Because the sorting occurs dynamically when computing application view state, these allocations cause avoidable lag and heap fragmentation.
📊 Impact: Removes unnecessary allocation spikes during frequent re-renders and re-sorts, significantly improving the framerate consistency when the tags sort is active.
🔬 Measurement: Use the b hotkey in settings to run local benchmarks (or monitor memory allocation/lag while scrolling/sorting).


PR created automatically by Jules for task 1502315767318017684 started by @damacus


Open with Devin

Replaces `.join(", ")` inside `sort_by` loops with a direct lexicographical
comparison of `Vec<String>`. Doing this drops expensive string allocations
(and multiple iterations over the slices to build the string) that previously
caused O(N log N) hidden heap allocations during the hot loop in TUI rendering.

Co-authored-by: damacus <40786+damacus@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
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.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Replaces `.join(", ")` inside `sort_by` loops with a direct lexicographical
comparison of `Vec<String>`. Doing this drops expensive string allocations
(and multiple iterations over the slices to build the string) that previously
caused O(N log N) hidden heap allocations during the hot loop in TUI rendering.

Also derives `Default` on `RunnerDiscoveryMode` to fix a clippy warning.

Co-authored-by: damacus <40786+damacus@users.noreply.github.com>
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