refactor(split-chunks): speed up module group processing#13322
refactor(split-chunks): speed up module group processing#13322LingyuCoder wants to merge 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors split-chunks module group processing to improve performance by reducing invalidation scope and optimizing module-group winner selection.
Changes:
- Introduces a reverse index to narrow invalidation to only affected module groups.
- Replaces linear “best module group” selection with a
BinaryHeap+ lazy invalidation queue. - Avoids repeated
SplitChunkSizescloning by returning references in theminSizevalidation path.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rspack_plugin_split_chunks/src/plugin/module_group.rs | Adds reverse index + heap-based queue; updates invalidation/refresh workflow. |
| crates/rspack_plugin_split_chunks/src/plugin/mod.rs | Switches main loop to heap-based selection and passes new validation context/index. |
| crates/rspack_plugin_split_chunks/src/plugin/min_size.rs | Updates container trait to return &SplitChunkSizes and avoids cloning in validation. |
| crates/rspack_plugin_split_chunks/src/module_group.rs | Adjusts APIs (collect_source_types_modules, get_sizes) and adds ordered module identifier helper. |
| crates/rspack_plugin_esm_library/src/split_chunks.rs | Aligns get_sizes behavior with reference-return refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff Analysis
Found 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 14.63KB from 49.04MB to 49.06MB (⬆️0.03%) |
Merging this PR will degrade performance by 3.93%🎉 Hooray!
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | rust@split_chunks |
9.1 ms | 9.4 ms | -3.93% |
Comparing codex/split-chunks-affected-index (3def2b0) with main (5f17956)
Footnotes
-
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. ↩
|
📝 Benchmark detail: Open task failure |
2467e29 to
1ed22bd
Compare
3d05c37 to
85b9876
Compare
85b9876 to
1c43b30
Compare
7fe21de to
988ffb3
Compare
|
@codspeed explain the perf diff |
Here's my analysis of the performance report for this PR: Performance Summary
The improvement:
|
96c1ca4 to
3def2b0
Compare
Summary
This PR focuses on reducing
splitChunksoverhead inrspack_plugin_split_chunks, especially around module group preparation, winner selection, and repeated post-processing.Key changes:
AffectedModuleGroupIndex, so we only revisit module groups that actually share both modules and chunks with the winner.BinaryHeap-basedModuleGroupQueueplus lazy version invalidation, while keeping deterministic tie-breaking.prepare_module_group_mapwhenchunks/test/name/layerdo not require async or dynamic evaluation, avoiding the previous sharedDashMapwrite contention.minSize-path clone overhead by returning borrowedSplitChunkSizesand collecting source-type modules intoVec<ModuleIdentifier>instead of cloning full sets.f64::total_cmpswap_removeordered_module_identifiersAdditional plumbing:
has_custom_layer_filterto detect whether the static fast path is saferspack_plugin_esm_libraryLocal validation:
cargo fmt --all --checkcargo clippy -p rspack_plugin_split_chunks -- -D warningsRelated links
Checklist