Skip to content

revert: perf: napi communication (#11132)#11162

Merged
stormslowly merged 1 commit intomainfrom
fix/large_dy_import_downgrade
Jul 24, 2025
Merged

revert: perf: napi communication (#11132)#11162
stormslowly merged 1 commit intomainfrom
fix/large_dy_import_downgrade

Conversation

@stormslowly
Copy link
Contributor

@stormslowly stormslowly commented Jul 24, 2025

Summary

This reverts commit 25000a7.
The commits downgrades some performance.

Related links

Checklist

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

Copilot AI review requested due to automatic review settings July 24, 2025 08:52
@netlify
Copy link

netlify bot commented Jul 24, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit d7fe5c4
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6881f4406709490008c31559

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Jul 24, 2025
Copy link
Contributor

Copilot AI left a comment

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 reverts a previous performance optimization related to NAPI communication between TypeScript and Rust components in the Rspack build system. The revert removes optimizations that were likely causing issues, restoring the previous implementation approach.

Key changes include:

  • Revert from direct NAPI object passing to JSON string serialization in normal module factory hooks
  • Remove caching optimizations and thread-local storage buffers used for performance
  • Restore HashMap usage instead of UkeyMap in core Rust module graph structures

Reviewed Changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/rspack/src/taps/normalModuleFactory.ts Reverts from direct NAPI object parameter to JSON string parsing for after-resolve data
packages/rspack/src/builtin-plugin/ExternalsPlugin.ts Removes caching optimization and restores inline JSON parsing for resolve requests
packages/rspack/etc/core.api.md Updates API signature to require compiler parameter in ExternalsPlugin raw method
crates/rspack_core/src/module_graph/mod.rs Reverts from UkeyMap back to HashMap for dependency and connection storage
crates/rspack_binding_api/src/resource_data.rs Removes thread-local property buffer optimization for resource data serialization
crates/rspack_binding_api/src/raw_options/raw_external.rs Simplifies external item context structure and removes complex closure context management
crates/rspack_binding_api/src/plugins/interceptor.rs Updates hook registration to use direct NAPI objects instead of JSON strings
crates/rspack_binding_api/src/normal_module_factory.rs Removes serde serialization derives and adds NAPI object attributes
crates/rspack_binding_api/src/modules/ Removes thread-local property buffers across all module types
crates/rspack_binding_api/src/module_graph.rs Removes connection vector buffer and simplifies return types
crates/rspack_binding_api/src/compilation/mod.rs Simplifies module collection without intermediate arrays
crates/rspack_binding_api/Cargo.toml Removes rayon dependency
Comments suppressed due to low confidence (1)

packages/rspack/src/builtin-plugin/ExternalsPlugin.ts:83

  • The variable names 'res' and 'rej' are abbreviated and unclear. Consider using more descriptive names like 'resolve' and 'reject' to match the standard Promise constructor pattern.
									return new Promise((res, rej) => {

@github-actions
Copy link
Contributor

github-actions bot commented Jul 24, 2025

📝 Benchmark detail: Open

Name Base (2025-07-24 ea8059e) Current Change
10000_big_production-mode_disable-minimize + exec 30.4 s ± 1.03 s 31 s ± 1.32 s +1.89 %
10000_development-mode + exec 1.77 s ± 121 ms 1.77 s ± 30 ms -0.21 %
10000_development-mode_hmr + exec 693 ms ± 19 ms 693 ms ± 21 ms +0.11 %
10000_production-mode + exec 1.82 s ± 47 ms 1.84 s ± 45 ms +1.05 %
10000_production-mode_persistent-cold + exec 1.95 s ± 12 ms 2 s ± 71 ms +2.49 %
10000_production-mode_persistent-hot + exec 1.42 s ± 72 ms 1.45 s ± 18 ms +1.52 %
arco-pro_development-mode + exec 1.78 s ± 126 ms 1.79 s ± 72 ms +0.86 %
arco-pro_development-mode_hmr + exec 368 ms ± 1.3 ms 365 ms ± 1.9 ms -0.83 %
arco-pro_production-mode + exec 3.29 s ± 146 ms 3.31 s ± 97 ms +0.39 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.34 s ± 65 ms 3.42 s ± 129 ms +2.30 %
arco-pro_production-mode_persistent-cold + exec 3.37 s ± 127 ms 3.4 s ± 75 ms +0.82 %
arco-pro_production-mode_persistent-hot + exec 2.09 s ± 95 ms 2.12 s ± 34 ms +1.44 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.28 s ± 72 ms 3.38 s ± 75 ms +2.76 %
large-dyn-imports_development-mode + exec 1.95 s ± 47 ms 2.01 s ± 51 ms +3.14 %
large-dyn-imports_production-mode + exec 2.02 s ± 45 ms 2.04 s ± 36 ms +1.04 %
threejs_development-mode_10x + exec 1.52 s ± 24 ms 1.52 s ± 17 ms -0.03 %
threejs_development-mode_10x_hmr + exec 920 ms ± 6.6 ms 917 ms ± 15 ms -0.38 %
threejs_production-mode_10x + exec 4.61 s ± 175 ms 4.63 s ± 27 ms +0.39 %
threejs_production-mode_10x_persistent-cold + exec 4.75 s ± 162 ms 4.83 s ± 344 ms +1.84 %
threejs_production-mode_10x_persistent-hot + exec 4.17 s ± 55 ms 4.25 s ± 310 ms +2.06 %
10000_big_production-mode_disable-minimize + rss memory 9738 MiB ± 417 MiB 9616 MiB ± 97.2 MiB -1.26 %
10000_development-mode + rss memory 684 MiB ± 12 MiB 678 MiB ± 14.9 MiB -0.79 %
10000_development-mode_hmr + rss memory 832 MiB ± 42.7 MiB 827 MiB ± 30.2 MiB -0.63 %
10000_production-mode + rss memory 651 MiB ± 31.2 MiB 645 MiB ± 46.2 MiB -0.92 %
10000_production-mode_persistent-cold + rss memory 757 MiB ± 30.5 MiB 746 MiB ± 55.7 MiB -1.50 %
10000_production-mode_persistent-hot + rss memory 736 MiB ± 19.7 MiB 739 MiB ± 34.4 MiB +0.36 %
arco-pro_development-mode + rss memory 621 MiB ± 69.9 MiB 585 MiB ± 45.2 MiB -5.68 %
arco-pro_development-mode_hmr + rss memory 526 MiB ± 35 MiB 479 MiB ± 28.4 MiB -8.95 %
arco-pro_production-mode + rss memory 709 MiB ± 59.1 MiB 696 MiB ± 124 MiB -1.80 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 704 MiB ± 90.9 MiB 712 MiB ± 116 MiB +1.04 %
arco-pro_production-mode_persistent-cold + rss memory 819 MiB ± 56.1 MiB 755 MiB ± 56.9 MiB -7.90 %
arco-pro_production-mode_persistent-hot + rss memory 656 MiB ± 58.4 MiB 646 MiB ± 92.7 MiB -1.48 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 713 MiB ± 44.5 MiB 684 MiB ± 66.9 MiB -4.02 %
large-dyn-imports_development-mode + rss memory 707 MiB ± 9.02 MiB 692 MiB ± 7.3 MiB -2.20 %
large-dyn-imports_production-mode + rss memory 637 MiB ± 11.6 MiB 619 MiB ± 4.12 MiB -2.81 %
threejs_development-mode_10x + rss memory 622 MiB ± 15.7 MiB 603 MiB ± 12.1 MiB -2.91 %
threejs_development-mode_10x_hmr + rss memory 831 MiB ± 65.9 MiB 810 MiB ± 73 MiB -2.54 %
threejs_production-mode_10x + rss memory 819 MiB ± 205 MiB 761 MiB ± 142 MiB -7.12 %
threejs_production-mode_10x_persistent-cold + rss memory 835 MiB ± 20.2 MiB 821 MiB ± 25.2 MiB -1.69 %
threejs_production-mode_10x_persistent-hot + rss memory 713 MiB ± 27 MiB 702 MiB ± 24 MiB -1.57 %

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing d7fe5c4 to chore: release v1.4.10 (#11156) by neverland

❌ Size increased by 15.13KB from 49.03MB to 49.05MB (⬆️0.03%)

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 24, 2025

CodSpeed Performance Report

Merging #11162 will not alter performance

Comparing fix/large_dy_import_downgrade (d7fe5c4) with main (7304bf0)

🎉 Hooray! codspeed-node just leveled up to 4.0.1!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 16 untouched benchmarks

@stormslowly stormslowly marked this pull request as draft July 24, 2025 10:53
@stormslowly stormslowly marked this pull request as ready for review July 24, 2025 12:18
@stormslowly stormslowly merged commit f70460b into main Jul 24, 2025
103 of 108 checks passed
@stormslowly stormslowly deleted the fix/large_dy_import_downgrade branch July 24, 2025 12:19
SyMind added a commit that referenced this pull request Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants