Skip to content

⚡ Bolt: [performance improvement] Prevent O(N) re-renders in WebSocket panels#143

Draft
primoscope wants to merge 1 commit intomainfrom
bolt-performance-optimization-902284516847375834
Draft

⚡ Bolt: [performance improvement] Prevent O(N) re-renders in WebSocket panels#143
primoscope wants to merge 1 commit intomainfrom
bolt-performance-optimization-902284516847375834

Conversation

@primoscope
Copy link
Copy Markdown
Owner

💡 What: The patch optimizes ProgressPanel.tsx and LogPanel.tsx by extracting the inner mapped elements (DownloadItem and LogItem) into their own components and wrapping them in React.memo(). Static helper functions (formatSpeed, getStatusColor) were moved outside of the components. A custom dynamic shallow-comparison function was added for DownloadItem to prevent updates when object references change but primitive data remains the same. Stable IDs were introduced for LogItem instead of using array indexes as keys.

🎯 Why: High-frequency WebSocket updates in ProgressPanel and LogPanel were causing O(N) re-renders of the entire list whenever a single item was updated or appended. Using array indexes as keys in LogPanel or relying on unmemoized items leads to significant performance degradation as the lists grow.

📊 Impact: Reduces list rendering time from O(N) to O(1) for item updates and appends. Massively decreases CPU usage and jank in the frontend when handling rapid WebSocket logs and progress events.

🔬 Measurement: Verify by starting a large batch download in the backend. Inspect React Developer Tools (Profiler) to observe that only the active/updating row in the ProgressPanel re-renders, rather than the whole list, and that existing elements in LogPanel are skipped during reconciliation.


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

* Wrap DownloadItem and LogItem in React.memo
* Extract static helper functions outside components
* Create custom dynamic shallow equality check for download items
* Generate stable IDs for WebSocket log objects

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