Skip to content

⚡ Bolt: Use Cached Metadata to Avoid UI Rendering Allocations - #148

Open
juntaochi wants to merge 1 commit into
mainfrom
bolt/ui-cached-metadata-1017169362803392720
Open

⚡ Bolt: Use Cached Metadata to Avoid UI Rendering Allocations#148
juntaochi wants to merge 1 commit into
mainfrom
bolt/ui-cached-metadata-1017169362803392720

Conversation

@juntaochi

Copy link
Copy Markdown
Owner

💡 What: Modified draw_metadata and draw_progress in src/ui/mod.rs to consume strings (Cow<'_, str>) directly from the application's metadata_cache (populated every ~500ms in App::update), instead of dynamically allocating strings like track.name.to_uppercase() and format!("{}/{}", ...) on every TUI frame.

🎯 Why: TUI applications re-render extremely frequently (typically at 60fps or when animated). Doing repeated heap string allocations (.to_uppercase() and format!) inside the hot draw path causes unnecessary memory churn and processing overhead. The string data only needs recalculation when the track identity or playback position actually changes, which is already handled efficiently in the background update loop.

📊 Impact: Significantly reduces heap allocations per frame by avoiding redundant formatting and casing logic. Ensures smoother animations (like text scrolling and throbbers) by removing garbage collection pressure.

🔬 Measurement: Verification passes cargo clippy -- -D warnings and cargo test. Rendering tests continue to function seamlessly as the implementation gracefully falls back to dynamic allocations (Cow::Owned) if the cache is omitted (e.g. in test mock environments).


PR created automatically by Jules for task 1017169362803392720 started by @juntaochi

Eliminates per-frame allocations for uppercase track metadata and gauge progress strings by leveraging the existing `metadata_cache` populated in the main `App::update` loop. Uses `Cow` to preserve lifetimes and gracefully fall back when the cache is absent.
@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.

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