Skip to content

⚡ Bolt: [performance improvement] React.memo list optimization#142

Draft
primoscope wants to merge 1 commit intomainfrom
bolt-react-memo-optimization-6500790666116220388
Draft

⚡ Bolt: [performance improvement] React.memo list optimization#142
primoscope wants to merge 1 commit intomainfrom
bolt-react-memo-optimization-6500790666116220388

Conversation

@primoscope
Copy link
Copy Markdown
Owner

💡 What

  • Extracted DownloadItem and LogItem into separate components and wrapped them in React.memo().
  • Added a custom equality function for DownloadItem to only re-render when visible primitive fields change.
  • Replaced array index keys with stable generated IDs for LogItem.
  • Moved static helper functions out of the component bodies to avoid recreation on every render.
  • Added explanatory comments for the performance optimizations.

🎯 Why

  • ProgressPanel: The ProgressPanel mapped over active downloads directly in its render block. During high-frequency WebSocket updates (which are common during fast downloads), the entire list of downloads would re-render for every single progress tick.
  • LogPanel: Similarly, the LogPanel mapped over logs and used array indices as keys. Appending a single new log message via WebSocket triggered a re-render of the entire historical log list.

📊 Impact

  • Substantially reduces React re-renders during high-frequency WebSocket updates (progress ticks, new logs).
  • LogPanel will only render the new log item being appended rather than the entire history.
  • ProgressPanel will only re-render the specific download item that received a progress or status update, leaving the rest of the active downloads list untouched.

🔬 Measurement

  1. Open the UI and start a download with many files/chunks.
  2. Open the React DevTools Profiler and record a session while the download is active.
  3. Observe that only the specific DownloadItem component re-renders when its progress changes, instead of the entire ProgressPanel and all its children.
  4. The same applies for incoming log messages in the LogPanel.

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

…ssPanel and LogPanel

Extracted DownloadItem and LogItem into separate components and wrapped them in React.memo. Added a custom equality check for DownloadItem to handle rapid updates efficiently and used a stable generated ID for LogItem to prevent complete re-renders of the lists when individual items are updated or appended via WebSocket. Helper functions were also moved out of the components to prevent recreation on every render.

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