perf(build): avoid encoding intermediate preload maps - #23461
Open
ShMcK wants to merge 3 commits into
Open
Conversation
ShMcK
marked this pull request as ready for review
September 10, 2026 04:25
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.
Preload rewriting generates an encoded temporary source map that
combineSourcemapsimmediately decodes. UsegenerateDecodedMap()to skip that round trip. The composer already accepts decoded maps; mapping precision (hires: 'boundary') and final encoded output stay the same.On a large production application with 25.5 MB of source maps, 10 measured builds per variant gave:
generateBundlehookThe hook improved in all 10 paired comparisons. Overall build timings overlap substantially, so this does not establish a reliable full-build speedup. All 3,463 output files, including maps, were byte-identical across 22 builds including warmups.
Review the three files in this order:
All CI checks pass, including type checking and the Linux/macOS/Windows test matrix.
Application measurement method and local verification
Vite 8.2.0, macOS arm64, Node 22.22.2. Output: 30.8 MB JavaScript and 25.5 MB source maps across 1,389 map files (uncompressed).
One warmup build per variant, then 10 measured pairs, alternating which variant runs first. Each build uses a fresh Vite process and cleared output; dependency libraries are already built. The measured bundle task does not use Turbo caching. Both variants use the same hook instrumentation.
Hook ranges: 576.69–675.49 ms before, 490.18–533.57 ms after. Full-invocation ranges: 4.641–5.254 s before, 4.533–4.882 s after.
Verification performed locally:
Run the microbenchmark, including a larger source map
After installing repository dependencies:
The script checks output equality and measures map generation/composition through
@jridgewell/remapping. It excludes Vite's path normalization and full build pipeline.On upstream base
9913672, macOS arm64, Node 26.8.1: five fresh processes per input size, each with five warmup pairs and 20 measured pairs in alternating order. Results below are medians of process medians; map sizes include source content.The larger case improved in four of five processes; one regressed (206.40 → 230.05 ms). These synthetic results are not full-build speedups or a guarantee that gains scale with map size.
AI assistance: Codex prepared the patch, tests, benchmark, and description; inspected the composition path; and ran the local checks above. Human author review is pending.