Skip to content

perf(module-concat): cheapen bailout reason generation#13609

Draft
LingyuCoder wants to merge 9 commits intomainfrom
codex/perf-module-concat-bailout-witness-impl
Draft

perf(module-concat): cheapen bailout reason generation#13609
LingyuCoder wants to merge 9 commits intomainfrom
codex/perf-module-concat-bailout-witness-impl

Conversation

@LingyuCoder
Copy link
Copy Markdown
Contributor

Summary

  • replace module concatenation bailout string assembly with a shared BailoutWitness model
  • make prefilter bailout generation use first-hit witnesses instead of collecting every export reason
  • make try_to_add bailouts record one deterministic witness for missing chunks, non-module references, cross-chunk importers, unsupported syntax importers, and runtime-dependent importers
  • cheapen hot-path witness selection so only the chosen witness is formatted late
  • update scope-hoisting/module-concatenation snapshot expectations to the new single-witness wording

Why

module_concatenation_plugin::try_to_add was doing extra hot-path work to build complete bailout messages, including collecting whole candidate sets, sorting them, and formatting aggregate strings. For bailout-heavy concatenation cases that overhead is unnecessary because a single sufficient witness is enough to explain the bailout.

Impact

  • keeps concatenation decisions unchanged
  • simplifies emitted bailout text to one deterministic witness
  • reduces work done in common bailout paths before formatting

Validation

  • cargo fmt --all --check
  • cargo lint
  • pnpm run build:cli:dev
  • pnpm run test:rs
  • pnpm run test -t "side-effects-optimization"
  • pnpm run test -t "scope-hoisting-multi"

Notes

  • local CodSpeed runs completed, but this environment only emitted Checked: ... rust@create_concatenate_module because CodSpeed reported an unknown environment, so no strict local numeric before/after claim is included here
  • pnpm run test:unit was not stable locally: repeated runs failed in different places (builtin-swc-loader timeout, Serial.test.js worker exit, Config.part1.test.js afterAll timeout), which looks more like suite/harness flakiness than a stable regression from this Rust-only change

@github-actions github-actions Bot added the team The issue/pr is created by the member of Rspack. label Apr 3, 2026
@github-actions

This comment was marked as outdated.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 3, 2026

Merging this PR will degrade performance by 5.56%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 16 untouched benchmarks
⏩ 19 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@concatenate_module_code_generation 142.3 ms 150.6 ms -5.56%
Simulation rust@create_concatenate_module 42.6 ms 34.1 ms +24.88%

Comparing codex/perf-module-concat-bailout-witness-impl (25d0e18) with main (c8abe3c)

Open in CodSpeed

Footnotes

  1. 19 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Rsdoctor Bundle Diff Analysis

Found 6 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB 0
react-10k 5.7 MB 0
rome 984.1 KB 0
react-1k 826.9 KB 0
react-5k 2.7 MB 0
ui-components 5.0 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

📦 Binary Size-limit

Comparing 25d0e18 to refactor: improve persistent cache load error handling (#13608) by jinrui

🎉 Size decreased by 9.97KB from 49.34MB to 49.33MB (⬇️0.02%)

@LingyuCoder LingyuCoder changed the title [codex] perf(module-concat): cheapen bailout reason generation perf(module-concat): cheapen bailout reason generation Apr 3, 2026
@github-actions github-actions Bot added the release: performance release: performance related release(mr only) label Apr 3, 2026
@github-actions

This comment was marked as outdated.

@LingyuCoder LingyuCoder force-pushed the codex/perf-module-concat-bailout-witness-impl branch from f01eadd to 0be7b28 Compare April 7, 2026 06:23
@github-actions

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

📝 Benchmark detail: Open

Name Base (4847e20) Current Change
10000_big_production-mode_disable-minimize + exec 14 s ± 295 ms 14 s ± 217 ms +0.17 %
10000_development-mode + exec 945 ms ± 28 ms 947 ms ± 15 ms +0.28 %
10000_development-mode_hmr + stats 175 ms ± 4.1 ms 177 ms ± 4.5 ms +1.60 %
10000_development-mode_noop-loader + exec 1.93 s ± 128 ms 1.97 s ± 106 ms +2.29 %
10000_production-mode + exec 1.09 s ± 28 ms 1.07 s ± 27 ms -1.12 %
10000_production-mode_persistent-cold + exec 1.24 s ± 12 ms 1.27 s ± 80 ms +2.13 %
10000_production-mode_persistent-hot + exec 925 ms ± 26 ms 928 ms ± 11 ms +0.30 %
10000_production-mode_source-map + exec 1.25 s ± 8.4 ms 1.24 s ± 40 ms -0.26 %
arco-pro_development-mode + exec 1.32 s ± 61 ms 1.34 s ± 61 ms +1.99 %
arco-pro_development-mode_hmr + stats 37 ms ± 1.2 ms 37 ms ± 0.79 ms -0.40 %
arco-pro_production-mode + exec 2.5 s ± 160 ms 2.47 s ± 79 ms -1.35 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 2.53 s ± 80 ms 2.53 s ± 78 ms +0.06 %
arco-pro_production-mode_persistent-cold + exec 2.55 s ± 100 ms 2.5 s ± 85 ms -1.85 %
arco-pro_production-mode_persistent-hot + exec 1.39 s ± 34 ms 1.39 s ± 28 ms -0.36 %
arco-pro_production-mode_source-map + exec 2.94 s ± 102 ms 2.97 s ± 184 ms +0.95 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.49 s ± 45 ms 2.5 s ± 45 ms +0.29 %
bundled-threejs_development-mode + exec 181 ms ± 6.3 ms 182 ms ± 3.7 ms +0.33 %
bundled-threejs_production-mode + exec 210 ms ± 3.5 ms 212 ms ± 9.1 ms +1.05 %
large-dyn-imports_development-mode + exec 1.19 s ± 29 ms 1.19 s ± 27 ms +0.29 %
large-dyn-imports_production-mode + exec 1.3 s ± 38 ms 1.32 s ± 67 ms +1.48 %
threejs_development-mode_10x + exec 824 ms ± 13 ms 832 ms ± 11 ms +1.02 %
threejs_development-mode_10x_hmr + stats 120 ms ± 3.5 ms 121 ms ± 4.5 ms +1.34 %
threejs_production-mode_10x + exec 3.04 s ± 56 ms 3.04 s ± 75 ms +0.06 %
threejs_production-mode_10x_persistent-cold + exec 3.19 s ± 159 ms 3.14 s ± 34 ms -1.40 %
threejs_production-mode_10x_persistent-hot + exec 2.54 s ± 21 ms 2.55 s ± 70 ms +0.24 %
threejs_production-mode_10x_source-map + exec 3.79 s ± 37 ms 3.83 s ± 165 ms +1.04 %
10000_big_production-mode_disable-minimize + rss memory 1955 MiB ± 57.8 MiB 1963 MiB ± 30.9 MiB +0.40 %
10000_development-mode + rss memory 574 MiB ± 10.3 MiB 575 MiB ± 16.3 MiB +0.17 %
10000_development-mode_hmr + rss memory 803 MiB ± 35.2 MiB 786 MiB ± 38.6 MiB -2.13 %
10000_development-mode_noop-loader + rss memory 863 MiB ± 11.6 MiB 863 MiB ± 10.7 MiB +0.07 %
10000_production-mode + rss memory 506 MiB ± 15.7 MiB 507 MiB ± 5.03 MiB +0.27 %
10000_production-mode_persistent-cold + rss memory 689 MiB ± 10.5 MiB 690 MiB ± 17.5 MiB +0.16 %
10000_production-mode_persistent-hot + rss memory 666 MiB ± 14.6 MiB 668 MiB ± 23.8 MiB +0.34 %
10000_production-mode_source-map + rss memory 534 MiB ± 6.61 MiB 532 MiB ± 19.7 MiB -0.40 %
arco-pro_development-mode + rss memory 479 MiB ± 10.6 MiB 478 MiB ± 9.07 MiB -0.15 %
arco-pro_development-mode_hmr + rss memory 491 MiB ± 7.93 MiB 494 MiB ± 4.59 MiB +0.49 %
arco-pro_production-mode + rss memory 658 MiB ± 14.2 MiB 656 MiB ± 22.2 MiB -0.37 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 674 MiB ± 14.8 MiB 678 MiB ± 9.36 MiB +0.56 %
arco-pro_production-mode_persistent-cold + rss memory 727 MiB ± 13.2 MiB 729 MiB ± 10.8 MiB +0.26 %
arco-pro_production-mode_persistent-hot + rss memory 534 MiB ± 14.5 MiB 535 MiB ± 22.6 MiB +0.15 %
arco-pro_production-mode_source-map + rss memory 747 MiB ± 15.8 MiB 749 MiB ± 15.9 MiB +0.40 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 663 MiB ± 16.8 MiB 662 MiB ± 14.1 MiB -0.13 %
bundled-threejs_development-mode + rss memory 159 MiB ± 8.45 MiB 160 MiB ± 9.22 MiB +0.53 %
bundled-threejs_production-mode + rss memory 183 MiB ± 4.56 MiB 182 MiB ± 5.52 MiB -0.17 %
large-dyn-imports_development-mode + rss memory 567 MiB ± 34.3 MiB 570 MiB ± 26.1 MiB +0.48 %
large-dyn-imports_production-mode + rss memory 446 MiB ± 9.03 MiB 451 MiB ± 9.58 MiB +1.14 %
threejs_development-mode_10x + rss memory 538 MiB ± 15 MiB 540 MiB ± 18.6 MiB +0.42 %
threejs_development-mode_10x_hmr + rss memory 671 MiB ± 11.2 MiB 671 MiB ± 16.6 MiB -0.02 %
threejs_production-mode_10x + rss memory 694 MiB ± 17.6 MiB 695 MiB ± 25.9 MiB +0.18 %
threejs_production-mode_10x_persistent-cold + rss memory 817 MiB ± 16.4 MiB 813 MiB ± 16.1 MiB -0.57 %
threejs_production-mode_10x_persistent-hot + rss memory 588 MiB ± 6.39 MiB 588 MiB ± 11.9 MiB -0.07 %
threejs_production-mode_10x_source-map + rss memory 811 MiB ± 18.3 MiB 805 MiB ± 17.7 MiB -0.83 %

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: performance release: performance related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant