perf: pack ExportInfo inline-exports flags into a bitfield#21171
Conversation
Replace the four per-ExportInfo inline-exports fields (canInlineProvide, canInlineUse, pureProvide, immutableBinding) with one value slot plus one numeric bitfield behind accessors, and omit the three provide-side keys from serialized RestoreProvidedData export entries when unset, so builds that never compute inline-exports data don't pay for it in heap or in the persistent cache. https://claude.ai/code/session_01MeAdSFqXFn7sqdeMg426vi
🦋 Changeset detectedLatest commit: 2e5c4e6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (1d12785). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@1d12785
yarn add -D webpack@https://pkg.pr.new/webpack@1d12785
pnpm add -D webpack@https://pkg.pr.new/webpack@1d12785 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21171 +/- ##
==========================================
+ Coverage 92.58% 92.59% +0.01%
==========================================
Files 587 586 -1
Lines 63666 63787 +121
Branches 17636 17678 +42
==========================================
+ Hits 58946 59065 +119
- Misses 4720 4722 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "future-defaults", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
254.5 KB | 676.1 KB | -62.35% |
| ❌ | Memory | benchmark "side-effects-reexport", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
758.1 KB | 1,190.4 KB | -36.31% |
| ❌ | Memory | benchmark "concatenate-modules", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
518.3 KB | 677.3 KB | -23.48% |
| ⚡ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,299.6 KB | 387.7 KB | ×3.4 |
| ⚡ | Memory | benchmark "many-modules-esm", scenario '{"name":"mode-production","mode":"production"}' |
9.1 MB | 7.1 MB | +27.53% |
| ⚡ | Memory | benchmark "many-chunks-esm", scenario '{"name":"mode-production","mode":"production"}' |
8.7 MB | 7 MB | +24.11% |
| ⚡ | Memory | benchmark "many-chunks-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
8.8 MB | 7.3 MB | +20.28% |
| ⚡ | Memory | benchmark "future-defaults", scenario '{"name":"mode-production","mode":"production"}' |
8.7 MB | 7.3 MB | +20.11% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing perf/export-info-inline-flags (2e5c4e6) with main (5f01ae5)
Footnotes
-
18 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. ↩
|
Regarding the 3 CodSpeed memory regressions (dev-rebuild scenarios): they don't reproduce locally. Measuring gc'd retained heap over 6 watch rebuilds of the actual benchmark cases, base vs this branch:
Run-to-run variance is ±300 KB — the same magnitude as the flagged deltas — and CodSpeed marked these comparisons as crossing different runtime environments. The MB-scale production-mode improvements (+20–27%) are consistent with the intent of the change (16 bytes saved per Also note Generated by Claude Code |
Summary
Reduce per-
ExportInfomemory (160 → 144 bytes per instance) and persistent-cache size by packing the four inline-exports fields into a value slot plus a bitfield behind same-named accessors, and skipping serialization of the three provide-side fields when unset (always the case in development, where inlining never runs).What kind of change does this PR introduce?
perf
Did you add tests for your changes?
No — behavior is unchanged (production bundles are byte-identical); covered by existing unit tests and the inline-exports config/cache test cases.
Does this PR introduce a breaking change?
No — the public property names and semantics on
ExportInfoare preserved via accessors.If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
This change was implemented with Claude Code under human direction: the AI wrote the code and changeset, verified value domains at every call site, and validated via the existing test suites plus before/after heap and cache-size benchmarks.
https://claude.ai/code/session_01MeAdSFqXFn7sqdeMg426vi
Generated by Claude Code