Skip to content

perf(hmr): no need to get assets info - #6296

Merged
chenjiahan merged 2 commits into
mainfrom
hmr_assets_1001
Oct 2, 2025
Merged

perf(hmr): no need to get assets info#6296
chenjiahan merged 2 commits into
mainfrom
hmr_assets_1001

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

When using stats.toJson in Rspack, enabling the assets: true option introduces noticeable Rust-JS communication overhead — typically a few milliseconds for small applications, but potentially several hundred milliseconds for large ones.

This PR avoids that overhead by checking stats.hash instead of relying on asset.emitted.

Before

Screenshot 2025-10-01 at 22 05 15

After

Screenshot 2025-10-01 at 22 04 46

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings October 1, 2025 14:10
@netlify

netlify Bot commented Oct 1, 2025

Copy link
Copy Markdown

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit f711885
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/68ddc05a48efaf00084feb88
😎 Deploy Preview https://deploy-preview-6296--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 49 (🔴 down 15 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes Hot Module Replacement (HMR) performance by eliminating the need to retrieve asset information during stats processing. Instead of checking asset.emitted to determine if files have changed, it now tracks build hashes to detect changes, reducing Rust-JS communication overhead.

  • Introduces hash-based change detection using a Map to store previous build hashes
  • Removes dependency on asset information (assets: true) from stats options
  • Optimizes the condition for skipping HMR updates when no changes are detected

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/core/src/server/socketServer.ts Outdated
Comment thread packages/core/src/server/socketServer.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chenjiahan
chenjiahan merged commit 5da6baf into main Oct 2, 2025
10 checks passed
@chenjiahan
chenjiahan deleted the hmr_assets_1001 branch October 2, 2025 00:26
@chenjiahan chenjiahan mentioned this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants