Skip to content

⚡ Bolt: Optimize high-frequency WebSocket rendering#144

Draft
primoscope wants to merge 1 commit intomainfrom
bolt/ws-render-optimization-5281709924120993204
Draft

⚡ Bolt: Optimize high-frequency WebSocket rendering#144
primoscope wants to merge 1 commit intomainfrom
bolt/ws-render-optimization-5281709924120993204

Conversation

@primoscope
Copy link
Copy Markdown
Owner

💡 What

  • Extracted LogItem and DownloadItem components wrapped in React.memo().
  • Implemented a custom shallow equality function for DownloadItem to only re-render when relevant primitive fields change.
  • Moved static helper functions (formatSpeed, formatETA, getStatusColor, getLogColor) outside the component body.
  • Replaced unreliable array index keys and crypto.randomUUID() with a safe, fallback-friendly ID generator (Date.now() + Math.random().toString()) for LogPanel items.

🎯 Why

In React components receiving high-frequency WebSocket updates (like ProgressPanel and LogPanel), directly rendering arrays of complex items inside the main component body leads to O(N) re-renders. This causes severe CPU spikes during active downloads. Furthermore, crypto.randomUUID() is undefined in non-secure contexts like HTTP, causing erratic behavior in self-hosted environments.

📊 Impact

  • Reduces main thread blocking by preventing O(N) reconciliation on every WebSocket tick.
  • CPU usage during active, high-speed downloads should decrease significantly.
  • Fixes potential rendering crashes in self-hosted (non-HTTPS) environments.

🔬 Measurement

  1. Open the application and start a large/fast download queue.
  2. Monitor CPU usage via Chrome DevTools Performance tab.
  3. Observe that only the actively updating rows in the Progress Panel and the new rows in the Log Panel trigger renders, instead of the entire list.

PR created automatically by Jules for task 5281709924120993204 started by @dzp5103

Extracted LogItem and DownloadItem into React.memo components to prevent O(N) re-renders during rapid WebSocket updates. Also moved static helper functions outside the render body and utilized safe, client-generated IDs for logs to ensure stability in non-secure HTTP contexts.

Co-authored-by: dzp5103 <214723817+dzp5103@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 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