You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: remove repeated module-graph work from ModuleConcatenationPlugin while preserving its root-by-root decisions, warning text, and deterministic ordering.
cache incoming-connection analysis and sorted incoming module identifiers per (module, runtime) for the lifetime of one optimization pass
keep root-specific chunk compatibility checks outside the shared cache
share immutable chunk sets, reuse per-root traversal buffers, and use RuntimeSpecMap for runtime-keyed caches
defer exact missing/different-chunk diagnostic materialization until warning formatting
parallelize only read-only bailout formatting, then apply module-graph mutations sequentially in original order
skip deferred-module lookup when experiments.deferImport is disabled
retain the existing comparable CodSpeed shared-roots workload and add rust@create_concatenate_module_bailouts for cross-chunk and recursive importer-failure coverage
The hot path runs once per candidate across thousands of possible roots. Previously, identical incoming sets were repeatedly collected, sorted, cloned, and allocated for each root.
Performance
Large synthetic support application, cold release-distribution validation with server concatenation enabled and caches cleared before every sample:
published @rspack/core 2.1.0: 58.08 s median (five runs)
local branch distribution 2.1.4: 29.07 s median (five runs)
end-to-end wall time: 49.95% lower (~2.0× faster)
This distribution-level comparison includes intervening main-branch changes; the plugin-specific profile below isolates the concatenation gain. Published 2.1.0 was 29.20 s median with server concatenation disabled, confirming that enabling the old implementation nearly doubled this app’s build time.
Large synthetic support application, no-trace plugin profiles:
server ModuleConcatenationPlugin: 10.47 s → 1.60–1.64 s (~84.5% faster)
server root-configuration search: 9.56 s → 0.86–0.89 s (~90.9% faster)
full profiled server build: 26.1 s → 17.4–17.6 s (~33% faster)
browser ModuleConcatenationPlugin, latest optimization versus the earlier PR revision: 5.19 s → 0.36 s (~93% faster)
The first cache pass improved the comparable shared-roots CodSpeed case from 16.835 ms to 14.121 ms (-15.7%, final rerun 14.511 ms) with no significant change in the disjoint-root case. Current-head CodSpeed reports a 3.03% aggregate improvement; the existing rust@create_concatenate_module case improved 14.4 ms → 13.9 ms (3.65% faster). The ecosystem benchmark completed successfully: every reported wall-time case improved (0.87–6.80%), with persistent-cache hit rates preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TL;DR: remove repeated module-graph work from
ModuleConcatenationPluginwhile preserving its root-by-root decisions, warning text, and deterministic ordering.(module, runtime)for the lifetime of one optimization passRuntimeSpecMapfor runtime-keyed cachesexperiments.deferImportis disabledrust@create_concatenate_module_bailoutsfor cross-chunk and recursive importer-failure coverageThe hot path runs once per candidate across thousands of possible roots. Previously, identical incoming sets were repeatedly collected, sorted, cloned, and allocated for each root.
Performance
Large synthetic support application, cold release-distribution validation with server concatenation enabled and caches cleared before every sample:
@rspack/core2.1.0: 58.08 s median (five runs)This distribution-level comparison includes intervening main-branch changes; the plugin-specific profile below isolates the concatenation gain. Published 2.1.0 was 29.20 s median with server concatenation disabled, confirming that enabling the old implementation nearly doubled this app’s build time.
Large synthetic support application, no-trace plugin profiles:
ModuleConcatenationPlugin: 10.47 s → 1.60–1.64 s (~84.5% faster)ModuleConcatenationPlugin, latest optimization versus the earlier PR revision: 5.19 s → 0.36 s (~93% faster)The first cache pass improved the comparable shared-roots CodSpeed case from 16.835 ms to 14.121 ms (-15.7%, final rerun 14.511 ms) with no significant change in the disjoint-root case. Current-head CodSpeed reports a 3.03% aggregate improvement; the existing
rust@create_concatenate_modulecase improved 14.4 ms → 13.9 ms (3.65% faster). The ecosystem benchmark completed successfully: every reported wall-time case improved (0.87–6.80%), with persistent-cache hit rates preserved.Correctness and risk
Veccollection and sequential graph writes preserve diagnostics orderReviewer guide
RuntimeIdentifierCache,CachedIncomingModules, andNoRuntimeModuleCache: cache key and lifetime changes.ModuleConcatenationPlugin::try_to_add: shared incoming analysis with root-specific compatibility decisions.optimize_chunk_modules_impl: scratch-buffer reuse and ordered parallel bailout formatting.compilation_stages.rs: unchanged historical shared-roots case plus the separate bailout-heavy case.Testing
pnpm run build:binding:releasepnpm run build:cli:devcargo test -p rspack_plugin_javascript— 33 passedStatsOutput.test.js— 153 passed-D warningspnpm run format:rsandpnpm run format:jspnpm run test:unit— 8,806 passed, 4 skipped; 3 acknowledged pre-existing browserslist fixture failures remainrspack_cacheableRelated links
N/A
Checklist