Skip to content

perf: reduce module concatenation hot-path overhead#14834

Open
LingyuCoder wants to merge 1 commit into
seal/module-concat-search-statefrom
seal/module-concat-hot-paths
Open

perf: reduce module concatenation hot-path overhead#14834
LingyuCoder wants to merge 1 commit into
seal/module-concat-search-statefrom
seal/module-concat-hot-paths

Conversation

@LingyuCoder

@LingyuCoder LingyuCoder commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Share unsupported-syntax bailout payloads instead of cloning their module lists.
  • Use cached-key sorting for repeated readable identifiers.
  • Clone root chunk state once per root search instead of once per candidate.

Related links

Checklist

  • Tests updated in the preceding stack layer.
  • Documentation not required.

@LingyuCoder LingyuCoder changed the title perf(module-concat): reduce remaining hot-path overhead perf: reduce module concatenation hot-path overhead Jul 17, 2026
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

📝 Benchmark detail: Open

Name Base (25274d8) Current Change
10000_big_production-mode_disable-minimize + exec 12.1 s ± 334 ms 12.1 s ± 352 ms -0.14 %
10000_development-mode + exec 895 ms ± 19 ms 905 ms ± 93 ms +1.12 %
10000_development-mode_hmr + stats 162 ms ± 18 ms 152 ms ± 3.4 ms -5.92 %
10000_development-mode_noop-loader + exec 1.78 s ± 135 ms 1.75 s ± 157 ms -1.80 %
10000_production-mode + exec 1.02 s ± 32 ms 1.02 s ± 26 ms -0.43 %
10000_production-mode_persistent-cold + exec 1.21 s ± 38 ms 1.17 s ± 42 ms -2.77 %
10000_production-mode_persistent-hot + exec 634 ms ± 12 ms 628 ms ± 8.2 ms -1.07 %
10000_production-mode_source-map + exec 1.21 s ± 97 ms 1.17 s ± 58 ms -3.54 %
arco-pro_development-mode + exec 1.25 s ± 40 ms 1.3 s ± 94 ms +4.10 %
arco-pro_development-mode_hmr + stats 33 ms ± 1.3 ms 33 ms ± 0.63 ms -1.86 %
arco-pro_production-mode + exec 2.34 s ± 154 ms 2.32 s ± 116 ms -0.77 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 2.42 s ± 84 ms 2.36 s ± 83 ms -2.50 %
arco-pro_production-mode_persistent-cold + exec 2.4 s ± 129 ms 2.39 s ± 65 ms -0.67 %
arco-pro_production-mode_persistent-hot + exec 344 ms ± 9 ms 339 ms ± 8.8 ms -1.28 %
arco-pro_production-mode_source-map + exec 2.84 s ± 68 ms 2.86 s ± 194 ms +0.56 %
arco-pro_production-mode_source-map_persistent-cold + exec 2.95 s ± 129 ms 2.87 s ± 104 ms -2.50 %
arco-pro_production-mode_source-map_persistent-hot + exec 477 ms ± 7.1 ms 483 ms ± 9.9 ms +1.17 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.37 s ± 143 ms 2.36 s ± 71 ms -0.50 %
bundled-threejs_development-mode + exec 181 ms ± 2.9 ms 181 ms ± 1.2 ms +0.11 %
bundled-threejs_production-mode + exec 208 ms ± 5.7 ms 208 ms ± 6.5 ms -0.10 %
large-dyn-imports_development-mode + exec 1.17 s ± 31 ms 1.17 s ± 27 ms +0.41 %
large-dyn-imports_production-mode + exec 1.27 s ± 30 ms 1.26 s ± 32 ms -0.77 %
threejs_development-mode_10x + exec 775 ms ± 13 ms 772 ms ± 31 ms -0.39 %
threejs_development-mode_10x_hmr + stats 112 ms ± 2.7 ms 110 ms ± 20 ms -1.81 %
threejs_production-mode_10x + exec 2.86 s ± 136 ms 2.81 s ± 42 ms -1.67 %
threejs_production-mode_10x_persistent-cold + exec 2.95 s ± 26 ms 2.91 s ± 29 ms -1.29 %
threejs_production-mode_10x_persistent-hot + exec 380 ms ± 7.9 ms 377 ms ± 11 ms -0.68 %
threejs_production-mode_10x_source-map + exec 3.66 s ± 179 ms 3.62 s ± 183 ms -1.24 %
10000_big_production-mode_disable-minimize + rss memory 2179 MiB ± 83.1 MiB 2217 MiB ± 23.4 MiB +1.79 %
10000_development-mode + rss memory 538 MiB ± 14 MiB 543 MiB ± 11.3 MiB +1.05 %
10000_development-mode_hmr + rss memory 788 MiB ± 40.7 MiB 794 MiB ± 30.1 MiB +0.88 %
10000_development-mode_noop-loader + rss memory 805 MiB ± 11.9 MiB 812 MiB ± 7.42 MiB +0.90 %
10000_production-mode + rss memory 466 MiB ± 9.03 MiB 471 MiB ± 10.9 MiB +1.05 %
10000_production-mode_persistent-cold + rss memory 662 MiB ± 11.1 MiB 665 MiB ± 11.5 MiB +0.37 %
10000_production-mode_persistent-hot + rss memory 649 MiB ± 33.8 MiB 666 MiB ± 24.7 MiB +2.68 %
10000_production-mode_source-map + rss memory 483 MiB ± 32.9 MiB 471 MiB ± 59 MiB -2.53 %
arco-pro_development-mode + rss memory 399 MiB ± 2.04 MiB 406 MiB ± 6.39 MiB +1.66 %
arco-pro_development-mode_hmr + rss memory 422 MiB ± 8.17 MiB 432 MiB ± 15 MiB +2.41 %
arco-pro_production-mode + rss memory 574 MiB ± 12.9 MiB 581 MiB ± 8.31 MiB +1.18 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 588 MiB ± 8.89 MiB 593 MiB ± 14.2 MiB +0.89 %
arco-pro_production-mode_persistent-cold + rss memory 660 MiB ± 26.3 MiB 661 MiB ± 11.9 MiB +0.16 %
arco-pro_production-mode_persistent-hot + rss memory 293 MiB ± 9.15 MiB 293 MiB ± 3.64 MiB -0.21 %
arco-pro_production-mode_source-map + rss memory 682 MiB ± 11.2 MiB 682 MiB ± 6.28 MiB -0.05 %
arco-pro_production-mode_source-map_persistent-cold + rss memory 812 MiB ± 37.6 MiB 811 MiB ± 24 MiB -0.08 %
arco-pro_production-mode_source-map_persistent-hot + rss memory 413 MiB ± 12.3 MiB 426 MiB ± 12 MiB +3.19 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 579 MiB ± 11.1 MiB 581 MiB ± 10.3 MiB +0.28 %
bundled-threejs_development-mode + rss memory 126 MiB ± 3.29 MiB 129 MiB ± 7.42 MiB +2.18 %
bundled-threejs_production-mode + rss memory 137 MiB ± 2.18 MiB 139 MiB ± 4.97 MiB +1.37 %
large-dyn-imports_development-mode + rss memory 553 MiB ± 20.4 MiB 553 MiB ± 17.5 MiB +0.02 %
large-dyn-imports_production-mode + rss memory 406 MiB ± 1.63 MiB 406 MiB ± 2.91 MiB +0.05 %
threejs_development-mode_10x + rss memory 432 MiB ± 9.74 MiB 435 MiB ± 4.68 MiB +0.83 %
threejs_development-mode_10x_hmr + rss memory 592 MiB ± 10.9 MiB 608 MiB ± 18.5 MiB +2.76 %
threejs_production-mode_10x + rss memory 615 MiB ± 22.8 MiB 616 MiB ± 23.4 MiB +0.11 %
threejs_production-mode_10x_persistent-cold + rss memory 576 MiB ± 12 MiB 571 MiB ± 8.94 MiB -1.01 %
threejs_production-mode_10x_persistent-hot + rss memory 378 MiB ± 7.36 MiB 375 MiB ± 10.3 MiB -0.69 %
threejs_production-mode_10x_source-map + rss memory 738 MiB ± 26.3 MiB 736 MiB ± 28.2 MiB -0.24 %

Base persistent cache hit rate: 👍

Current persistent cache hit rate: 👍

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 7cc987b to Merge 5bd606d24afa23162dac7ae8397a2295ba1d39b9 into 7d705ba6b17e919e1ea703aaa8278e1b2efa59ae by harpsealjs

⏳ The base commit triggered a linux binding build, but its binary size data has not been generated yet, so the size comparison is skipped.

Please re-run this workflow once the ecosystem-benchmark data for that commit is published.

Warning

Reference only — not the real baseline. The base commit's data isn't ready yet, so this compares against the nearest earlier commit that has data (5cfe1be) for a rough estimate:

❌ Size increased by 8.00KB from 66.66MB to 66.67MB (⬆️0.01%)

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
react-10k 5.6 MB 1.3 MB 0 0
popular-libs 1.7 MB 552.1 KB 0 0
react-1k 823.1 KB 217.0 KB 0 0
react-5k 2.7 MB 663.8 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 0.41%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 44 untouched benchmarks
⏩ 47 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@create_chunk_assets 1.4 ms 1.5 ms -3.02%
Simulation rust@create_concatenate_module_unsupported_syntax 18.1 ms 17.7 ms +2.27%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing seal/module-concat-hot-paths (7cc987b) with seal/module-concat-search-state (5bd606d)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Share unsupported-syntax payloads, use cached-key sorting for repeated identifiers, and clone root chunk state once per root search.

Co-authored-by: ScriptedAlchemy <zackary.l.jackson@gmail.com>
@LingyuCoder
LingyuCoder force-pushed the seal/module-concat-search-state branch from 6e442e8 to 5bd606d Compare July 21, 2026 07:44
@LingyuCoder
LingyuCoder force-pushed the seal/module-concat-hot-paths branch from 132119d to 7cc987b Compare July 21, 2026 07:44
@LingyuCoder
LingyuCoder marked this pull request as ready for review July 21, 2026 10:52
Copilot AI review requested due to automatic review settings July 21, 2026 10:52

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LingyuCoder

Copy link
Copy Markdown
Contributor Author

@codspeedbot explain the regression

@codspeed-hq

codspeed-hq Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@codspeedbot explain the regression

rust@create_chunk_assets regression: environment artifact, not a real regression

Short version: the flagged -3.02% (1.4 ms → 1.5 ms) on rust@create_chunk_assets is a measurement artifact from base and head running in different runtime environments, not an effect of this PR's code.

Evidence

1. Base and head ran on different runners. The comparison detected these environment differences, and create_chunk_assets is explicitly among the benchmarks whose base and head crossed them:

  • CPU: AMD EPYC 9V74 80-Core (base) → AMD EPYC 7763 64-Core (head)
  • linked library libm.so.6 differs between the two runs

In Simulation mode the CPU cycle estimate is derived from a cache model tied to the physical CPU, so a different CPU/toolchain shifts the estimate on byte-identical code. That's exactly what CodSpeed's "Different runtime environments detected" warning on the report is flagging.

2. This PR does not touch the create_chunk_assets code path. The changes are confined to module concatenation (crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs — the shared unsupported-syntax payloads, cached-key sorting, and per-root chunk-state clone). The create_chunk_assets hot path is output-filename template rendering in rspack_core (render_manifestrender_template → placeholder replacement), which none of these changes reach.

3. The benchmark is short and codegen-sensitive. create_chunk_assets is a ~1.4 ms Simulation stage bench; sub-~4% swings on it are routinely codegen/inlining/layout artifacts of the shared bench binary rather than real work changes. A 1.4 ms → 1.5 ms swing that only appears across a CPU + libm change is consistent with that.

On the flip side

The paired ⚡ +32.87% on sources@parse_source_map_from_json (9.9 ms → 7.5 ms) crossed the same environment difference, so it is not a real improvement from this PR either — it's the mirror image of the same cross-runner effect.

Recommendation

No source-level fix targets this — there's nothing in the module-concatenation change to correct. It's safe to acknowledge this regression on CodSpeed. If you'd like a clean signal, re-run once so base and head land on the same runner CPU; the real signal for this PR is the concatenation benchmarks (rust@create_concatenate_module_*), which are the ones this change actually affects.

Summary
  • Warming up the performance wizard...
  • Handling comment — Comment handling finished successfully

Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.

@LingyuCoder
LingyuCoder requested a review from JSerFeng July 21, 2026 11:08
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.

3 participants