perf: box large compilation artifacts#14699
Draft
intellild wants to merge 1 commit into
Draft
Conversation
Contributor
📦 Binary Size-limit
🎉 Size decreased by 16.00KB from 66.74MB to 66.73MB (⬇️0.02%) |
483fdd7 to
892a1cb
Compare
892a1cb to
ac8b64a
Compare
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
This PR boxes several large compilation artifacts across async and persistent-cache boundaries so they are no longer returned or moved by value through hot paths. The main flow now carries boxed build-module-graph artifacts, exports-info artifacts, build results, parse results, code-generation results, and persistent-cache artifacts.
It also simplifies the large
BindingCellconstructors back tonew(Box<T>), addsFrom<Box<T>>support where needed, and updates affected module/plugin implementations to keep large results boxed through the call chain.A new
rspack_large_stack_typedylint crate was added to catch known large Rspack types when they appear in stack-sized positions. The root lint config also enables relevant clippy/rust lints for large assignments, futures, and stack frames.Why
These artifacts can become large enough that returning or moving them by value increases stack pressure and unnecessary data movement. Boxing them at ownership boundaries keeps async futures and compilation-stage handoffs smaller while preserving the existing ownership model.
Expected impact
The change should reduce stack usage and large moves in build-module-graph, parser/build/codegen, and persistent-cache recovery paths. It also gives future changes a guardrail so new large artifacts are passed as
Boxor references instead of silently growing stack frames.Checked locally with
cargo fmt --all --check, focusedcargo checkfor core/devtool/swc-minimizer,cargo test --locked --no-runfor the new dylint crate,cargo check -p rspack_benchmark --benches, andcargo check --profile codspeed -p rspack_benchmark --bench benches --bench rspack_sources. The dylint UI run reached the temporary driver stage locally, but the driver process did not complete reliably in this environment.