Skip to content

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

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

perf(module-concat): cheapen bailout reason generation#13609
LingyuCoder wants to merge 4 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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

📝 Benchmark detail: Open

Name Base (c88a8d5) Current Change
10000_big_production-mode_disable-minimize + exec 14.2 s ± 271 ms 14.1 s ± 242 ms -0.68 %
10000_development-mode + exec 940 ms ± 51 ms 925 ms ± 22 ms -1.64 %
10000_development-mode_hmr + stats 180 ms ± 3.9 ms 175 ms ± 6.4 ms -2.59 %
10000_development-mode_noop-loader + exec 1.97 s ± 53 ms 1.94 s ± 54 ms -1.43 %
10000_production-mode + exec 1.09 s ± 53 ms 1.05 s ± 32 ms -3.25 %
10000_production-mode_persistent-cold + exec 1.25 s ± 39 ms 1.23 s ± 29 ms -1.44 %
10000_production-mode_persistent-hot + exec 923 ms ± 30 ms 907 ms ± 25 ms -1.82 %
10000_production-mode_source-map + exec 1.25 s ± 35 ms 1.23 s ± 28 ms -2.03 %
arco-pro_development-mode + exec 1.35 s ± 57 ms 1.31 s ± 69 ms -2.78 %
arco-pro_development-mode_hmr + stats 38 ms ± 0.58 ms 37 ms ± 1.1 ms -1.73 %
arco-pro_production-mode + exec 2.48 s ± 98 ms 2.44 s ± 43 ms -1.71 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 2.55 s ± 96 ms 2.51 s ± 84 ms -1.59 %
arco-pro_production-mode_persistent-cold + exec 2.49 s ± 106 ms 2.48 s ± 95 ms -0.42 %
arco-pro_production-mode_persistent-hot + exec 1.4 s ± 61 ms 1.38 s ± 34 ms -1.00 %
arco-pro_production-mode_source-map + exec 2.91 s ± 91 ms 2.89 s ± 202 ms -0.65 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.49 s ± 74 ms 2.46 s ± 80 ms -1.13 %
bundled-threejs_development-mode + exec 183 ms ± 2.5 ms 181 ms ± 3 ms -1.53 %
bundled-threejs_production-mode + exec 213 ms ± 2.5 ms 213 ms ± 8.1 ms -0.28 %
large-dyn-imports_development-mode + exec 1.18 s ± 10 ms 1.17 s ± 54 ms -0.64 %
large-dyn-imports_production-mode + exec 1.32 s ± 28 ms 1.3 s ± 33 ms -2.00 %
threejs_development-mode_10x + exec 826 ms ± 13 ms 822 ms ± 30 ms -0.51 %
threejs_development-mode_10x_hmr + stats 119 ms ± 3.8 ms 115 ms ± 3.2 ms -3.13 %
threejs_production-mode_10x + exec 3.07 s ± 23 ms 3.02 s ± 34 ms -1.55 %
threejs_production-mode_10x_persistent-cold + exec 3.25 s ± 85 ms 3.19 s ± 27 ms -1.84 %
threejs_production-mode_10x_persistent-hot + exec 2.56 s ± 44 ms 2.55 s ± 31 ms -0.45 %
threejs_production-mode_10x_source-map + exec 3.85 s ± 54 ms 3.81 s ± 82 ms -1.11 %
10000_big_production-mode_disable-minimize + rss memory 2005 MiB ± 70.4 MiB 1979 MiB ± 48.6 MiB -1.31 %
10000_development-mode + rss memory 595 MiB ± 17.3 MiB 592 MiB ± 16 MiB -0.50 %
10000_development-mode_hmr + rss memory 794 MiB ± 29.6 MiB 797 MiB ± 49.9 MiB +0.44 %
10000_development-mode_noop-loader + rss memory 886 MiB ± 9.06 MiB 885 MiB ± 12.6 MiB -0.14 %
10000_production-mode + rss memory 530 MiB ± 70.7 MiB 543 MiB ± 11.4 MiB +2.53 %
10000_production-mode_persistent-cold + rss memory 710 MiB ± 10.3 MiB 705 MiB ± 4.29 MiB -0.81 %
10000_production-mode_persistent-hot + rss memory 680 MiB ± 10.9 MiB 669 MiB ± 17.7 MiB -1.58 %
10000_production-mode_source-map + rss memory 563 MiB ± 8.29 MiB 559 MiB ± 17.4 MiB -0.80 %
arco-pro_development-mode + rss memory 477 MiB ± 8.98 MiB 476 MiB ± 6.52 MiB -0.24 %
arco-pro_development-mode_hmr + rss memory 493 MiB ± 13.8 MiB 492 MiB ± 9.98 MiB -0.18 %
arco-pro_production-mode + rss memory 661 MiB ± 61 MiB 652 MiB ± 60.5 MiB -1.44 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 681 MiB ± 58.8 MiB 687 MiB ± 13.2 MiB +0.93 %
arco-pro_production-mode_persistent-cold + rss memory 733 MiB ± 31 MiB 743 MiB ± 13.9 MiB +1.31 %
arco-pro_production-mode_persistent-hot + rss memory 543 MiB ± 22.8 MiB 537 MiB ± 20.5 MiB -1.01 %
arco-pro_production-mode_source-map + rss memory 761 MiB ± 24.1 MiB 758 MiB ± 30.2 MiB -0.38 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 678 MiB ± 18.5 MiB 677 MiB ± 10.1 MiB -0.14 %
bundled-threejs_development-mode + rss memory 158 MiB ± 13.7 MiB 160 MiB ± 10.7 MiB +1.55 %
bundled-threejs_production-mode + rss memory 180 MiB ± 8.6 MiB 178 MiB ± 10.1 MiB -0.62 %
large-dyn-imports_development-mode + rss memory 602 MiB ± 24.1 MiB 595 MiB ± 25.8 MiB -1.10 %
large-dyn-imports_production-mode + rss memory 469 MiB ± 13 MiB 467 MiB ± 13.6 MiB -0.45 %
threejs_development-mode_10x + rss memory 538 MiB ± 21.9 MiB 546 MiB ± 8.94 MiB +1.48 %
threejs_development-mode_10x_hmr + rss memory 673 MiB ± 21.2 MiB 671 MiB ± 14.5 MiB -0.32 %
threejs_production-mode_10x + rss memory 721 MiB ± 14.6 MiB 714 MiB ± 19.8 MiB -0.89 %
threejs_production-mode_10x_persistent-cold + rss memory 843 MiB ± 14.4 MiB 841 MiB ± 7.34 MiB -0.23 %
threejs_production-mode_10x_persistent-hot + rss memory 606 MiB ± 3.34 MiB 608 MiB ± 12 MiB +0.30 %
threejs_production-mode_10x_source-map + rss memory 825 MiB ± 26.9 MiB 817 MiB ± 18 MiB -0.91 %

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 3, 2026

Merging this PR will improve performance by 11.18%

⚡ 4 improved benchmarks
✅ 14 untouched benchmarks
⏩ 19 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@persistent_cache_restore_after_single_file_change@basic-react-development 27.9 ms 27.4 ms +1.94%
Simulation rust@create_chunk_ids 10.7 ms 10.5 ms +2.11%
Simulation rust@create_concatenate_module 42.2 ms 37.9 ms +11.18%
Simulation rust@concatenate_module_code_generation 147 ms 142 ms +3.48%

Comparing codex/perf-module-concat-bailout-witness-impl (58d48bc) with main (53b2c2f)

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

⚠️ Note: The latest commit (53b2c2feeb) does not have baseline artifacts. Using commit 5f19254e5e for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 6 projects in monorepo, 6 projects with changes.

📊 Quick Summary
Project Total Size Change
popular-libs 1.7 MB +617.0 B (0.0%)
react-10k 5.7 MB +20.0 B (0.0%)
react-1k 826.2 KB +20.0 B (0.0%)
rome 984.1 KB +1.0 B (0.0%)
react-5k 2.7 MB +20.0 B (0.0%)
ui-components 5.0 MB +638.0 B (0.0%)
📋 Detailed Reports (Click to expand)

📁 popular-libs

Path: ../build-tools-performance/cases/popular-libs/dist/rsdoctor-data.json

📌 Baseline Commit: 5f19254e5e | PR: #13614

Metric Current Baseline Change
📊 Total Size 1.7 MB 1.7 MB +617.0 B (0.0%)
📄 JavaScript 1.7 MB 1.7 MB +617.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: popular-libs Bundle Diff

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: 5f19254e5e | PR: #13614

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB +20.0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB +20.0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: 5f19254e5e | PR: #13614

Metric Current Baseline Change
📊 Total Size 826.2 KB 826.2 KB +20.0 B (0.0%)
📄 JavaScript 826.2 KB 826.2 KB +20.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-1k Bundle Diff

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: 5f19254e5e | PR: #13614

Metric Current Baseline Change
📊 Total Size 984.1 KB 984.1 KB +1.0 B (0.0%)
📄 JavaScript 984.1 KB 984.1 KB +1.0 B (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: rome Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: 5f19254e5e | PR: #13614

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB +20.0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB +20.0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-5k Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: 5f19254e5e | PR: #13614

Metric Current Baseline Change
📊 Total Size 5.0 MB 5.0 MB +638.0 B (0.0%)
📄 JavaScript 4.7 MB 4.7 MB +638.0 B (0.0%)
🎨 CSS 291.6 KB 291.6 KB 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

📦 Binary Size-limit

Comparing 58d48bc to chore(deps): update patch npm dependencies (#13615) by renovate[bot]

🎉 Size decreased by 10.97KB from 49.26MB to 49.25MB (⬇️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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

📝 Benchmark detail: Open

Name Base (c88a8d5) Current Change
10000_big_production-mode_disable-minimize + exec 14.2 s ± 271 ms 14.1 s ± 213 ms -0.75 %
10000_development-mode + exec 940 ms ± 51 ms 933 ms ± 18 ms -0.81 %
10000_development-mode_hmr + stats 180 ms ± 3.9 ms 177 ms ± 4.2 ms -1.37 %
10000_development-mode_noop-loader + exec 1.97 s ± 53 ms 1.95 s ± 90 ms -1.11 %
10000_production-mode + exec 1.09 s ± 53 ms 1.07 s ± 54 ms -1.60 %
10000_production-mode_persistent-cold + exec 1.25 s ± 39 ms 1.24 s ± 41 ms -0.58 %
10000_production-mode_persistent-hot + exec 923 ms ± 30 ms 923 ms ± 16 ms -0.04 %
10000_production-mode_source-map + exec 1.25 s ± 35 ms 1.25 s ± 43 ms +0.24 %
arco-pro_development-mode + exec 1.35 s ± 57 ms 1.34 s ± 93 ms -0.65 %
arco-pro_development-mode_hmr + stats 38 ms ± 0.58 ms 38 ms ± 3.1 ms -0.43 %
arco-pro_production-mode + exec 2.48 s ± 98 ms 2.49 s ± 85 ms +0.58 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 2.55 s ± 96 ms 2.53 s ± 118 ms -0.70 %
arco-pro_production-mode_persistent-cold + exec 2.49 s ± 106 ms 2.54 s ± 87 ms +1.93 %
arco-pro_production-mode_persistent-hot + exec 1.4 s ± 61 ms 1.4 s ± 52 ms +0.17 %
arco-pro_production-mode_source-map + exec 2.91 s ± 91 ms 2.9 s ± 109 ms -0.12 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.49 s ± 74 ms 2.49 s ± 67 ms +0.29 %
bundled-threejs_development-mode + exec 183 ms ± 2.5 ms 182 ms ± 2.9 ms -0.87 %
bundled-threejs_production-mode + exec 213 ms ± 2.5 ms 211 ms ± 3.7 ms -0.94 %
large-dyn-imports_development-mode + exec 1.18 s ± 10 ms 1.18 s ± 48 ms +0.05 %
large-dyn-imports_production-mode + exec 1.32 s ± 28 ms 1.32 s ± 26 ms +0.02 %
threejs_development-mode_10x + exec 826 ms ± 13 ms 820 ms ± 35 ms -0.68 %
threejs_development-mode_10x_hmr + stats 119 ms ± 3.8 ms 119 ms ± 2.2 ms +0.67 %
threejs_production-mode_10x + exec 3.07 s ± 23 ms 3.1 s ± 34 ms +0.99 %
threejs_production-mode_10x_persistent-cold + exec 3.25 s ± 85 ms 3.24 s ± 36 ms -0.42 %
threejs_production-mode_10x_persistent-hot + exec 2.56 s ± 44 ms 2.6 s ± 34 ms +1.44 %
threejs_production-mode_10x_source-map + exec 3.85 s ± 54 ms 3.86 s ± 51 ms +0.29 %
10000_big_production-mode_disable-minimize + rss memory 2005 MiB ± 70.4 MiB 1985 MiB ± 29.8 MiB -0.99 %
10000_development-mode + rss memory 595 MiB ± 17.3 MiB 585 MiB ± 3.26 MiB -1.72 %
10000_development-mode_hmr + rss memory 794 MiB ± 29.6 MiB 804 MiB ± 37 MiB +1.35 %
10000_development-mode_noop-loader + rss memory 886 MiB ± 9.06 MiB 879 MiB ± 20.2 MiB -0.74 %
10000_production-mode + rss memory 530 MiB ± 70.7 MiB 542 MiB ± 12.7 MiB +2.39 %
10000_production-mode_persistent-cold + rss memory 710 MiB ± 10.3 MiB 704 MiB ± 13.2 MiB -0.95 %
10000_production-mode_persistent-hot + rss memory 680 MiB ± 10.9 MiB 670 MiB ± 11.3 MiB -1.44 %
10000_production-mode_source-map + rss memory 563 MiB ± 8.29 MiB 566 MiB ± 13.3 MiB +0.49 %
arco-pro_development-mode + rss memory 477 MiB ± 8.98 MiB 478 MiB ± 11.7 MiB +0.28 %
arco-pro_development-mode_hmr + rss memory 493 MiB ± 13.8 MiB 491 MiB ± 10.3 MiB -0.43 %
arco-pro_production-mode + rss memory 661 MiB ± 61 MiB 650 MiB ± 62.2 MiB -1.67 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 681 MiB ± 58.8 MiB 686 MiB ± 12.6 MiB +0.74 %
arco-pro_production-mode_persistent-cold + rss memory 733 MiB ± 31 MiB 742 MiB ± 12.8 MiB +1.17 %
arco-pro_production-mode_persistent-hot + rss memory 543 MiB ± 22.8 MiB 538 MiB ± 20.6 MiB -0.88 %
arco-pro_production-mode_source-map + rss memory 761 MiB ± 24.1 MiB 760 MiB ± 10.4 MiB -0.03 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 678 MiB ± 18.5 MiB 674 MiB ± 8.16 MiB -0.53 %
bundled-threejs_development-mode + rss memory 158 MiB ± 13.7 MiB 158 MiB ± 8.77 MiB +0.27 %
bundled-threejs_production-mode + rss memory 180 MiB ± 8.6 MiB 177 MiB ± 8.36 MiB -1.54 %
large-dyn-imports_development-mode + rss memory 602 MiB ± 24.1 MiB 592 MiB ± 17.5 MiB -1.63 %
large-dyn-imports_production-mode + rss memory 469 MiB ± 13 MiB 466 MiB ± 8.44 MiB -0.83 %
threejs_development-mode_10x + rss memory 538 MiB ± 21.9 MiB 544 MiB ± 13.8 MiB +1.01 %
threejs_development-mode_10x_hmr + rss memory 673 MiB ± 21.2 MiB 677 MiB ± 13.4 MiB +0.54 %
threejs_production-mode_10x + rss memory 721 MiB ± 14.6 MiB 727 MiB ± 19.1 MiB +0.82 %
threejs_production-mode_10x_persistent-cold + rss memory 843 MiB ± 14.4 MiB 833 MiB ± 14.9 MiB -1.17 %
threejs_production-mode_10x_persistent-hot + rss memory 606 MiB ± 3.34 MiB 606 MiB ± 12.2 MiB -0.14 %
threejs_production-mode_10x_source-map + rss memory 825 MiB ± 26.9 MiB 828 MiB ± 32.4 MiB +0.33 %

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