[codex] Reuse prehashed resolver paths#13975
Draft
hardfist wants to merge 4 commits into
Draft
Conversation
Contributor
📦 Binary Size-limit
❌ Size increased by 4.00KB from 61.92MB to 61.92MB (⬆️0.01%) |
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
Rsdoctor Bundle Diff AnalysisFound 6 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
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.
Summary
ArcPathsets.ArcPath::from_path_buf_with_hashconstructor and makeArcPathequality check the cached hash before comparing full paths.rspack_resolverat the resolver PR branch so this draft can compile against the new API.Why
build_module_graphreceives dependency paths fromrspack_resolver, deduplicates them, and then converts them into Rspack's prehashedArcPathsets. Before this change, those paths were hashed again during conversion. This PR uses the prehashed resolver context from rstackjs/rspack-resolver#206 to avoid that extra fullPathhash work.The parser walk change removes two no-op JavaScript pre-walk traversals for modules where the pass cannot create bindings or module import/export dependencies. This produced a measurable instruction-count reduction locally, though it is still below the requested 10% target.
The rule matcher change hoists
ResourceData::path()once per rule set/single-rule match so sync and async rule checks can reuse the same&strwhile preserving the existing matching order and fallback behavior.The resolver dependency update avoids joining
package.jsonpaths repeatedly from the same cached directory during package-json reads and dependency recording.Dependency
Depends on rstackjs/rspack-resolver#206. Before this can be marked ready, replace the temporary git dependency with the published resolver version containing
ResolvePreHashedContext.Micro-Optimization Progress
Target benchmark:
rust@build_module_graphMeasurement mode: local Criterion plus Callgrind/CodSpeed Valgrind fork
Primary metric: Callgrind
Irfor the benchmark useful segment0394d0afcfrust@build_module_graph[176.32 ms 184.60 ms 193.61 ms][172.44 ms 191.84 ms 218.00 ms]cargo check -p rspack_paths -p rspack_core;cargo test -p rspack_paths7a21e93b80rust@build_module_graphIr4,380,134,8364,217,447,382-3.7%cargo fmt --check;cargo check -p rspack_plugin_javascript;cargo test -p rspack_plugin_javascript --lib[172.89 ms 177.90 ms 183.45 ms], no statistically significant change.f7df7f257brust@build_module_graphIr4,217,447,3824,215,709,867-0.04%cargo fmt --check;cargo check -p rspack_core;cargo test -p rspack_core module_rules745d1cd351rust@build_module_graphIr4,215,709,8674,177,020,822-0.92%cargo check -p rspack_core; resolvercargo fmt --check; resolvercargo check; resolvercargo test package_jsonc5d3b9df, which caches package-json path joins. Resolver fullcargo testwas attempted: 124 passed, 6 PnP fixture tests failed withNotFound(...).Validation
cargo check -p rspack_paths -p rspack_corecargo test -p rspack_pathscargo fmt --checkcargo check -p rspack_plugin_javascriptcargo test -p rspack_plugin_javascript --libcargo check -p rspack_corecargo test -p rspack_core module_rulescargo check -p rspack_corecargo fmt --checkcargo checkcargo test package_json