opt(#239 Phase A): component custom-section GC (producers/name/.debug_*, opt-in component-type)#253
Open
avrabe wants to merge 1 commit into
Open
opt(#239 Phase A): component custom-section GC (producers/name/.debug_*, opt-in component-type)#253avrabe wants to merge 1 commit into
avrabe wants to merge 1 commit into
Conversation
Strip semantically-inert component-level custom sections during component optimization, and extend the strip into nested core modules. - Strip component-level `producers`, `name`/`component-name`, and `.debug_*` in `reconstruct_component` (byte-range aware: only sections OUTSIDE every nested core-module range; module-level sections are handled by the module re-encode path). - `component-type` metadata: default-PRESERVE (wit-component introspection depends on it); strip only behind the opt-in `ComponentOptimizeConfig .strip_component_type` / CLI `--strip-component-type`. - Nested core modules: new `strip_inert_module_sections` (extends the #244 `.debug_*`/name handling to also drop `name`/`producers`), run in the component core-module path before final encode. - CLI size-breakdown report (core code vs component types vs custom stripped), before to after, so the win is attributable. Proof: every transform is a strip of an execution-inert custom section (trivially sound); outputs are wasm-tools-validated and WIT-round-tripped. On the shipped fixtures: calc 442 to 235 bytes, simple 261 to 100 bytes; both validate and `wasm-tools component wit` still resolves. Unit/integration tests cover default-strip, component-type preserve-vs-opt-in-strip, unknown custom-section preservation, and the matchers. Full workspace test suite green. Implements: #239 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Refs #239 (Phase A of 3). Strips semantically-inert custom sections from components — the component-level layer that
component_optimizer.rsnever touched.What
producers,name/component-name,.debug_*at the component level during reconstruction (byte-range-aware, so nested-module sections aren't misclassified).component-type: default-PRESERVE (WIT/wit-componentintrospection depends on it); stripped only behind opt-in--strip-component-type.name/producerson the component's nested-core-module path (strip_inert_module_sections).Soundness
Inert custom sections don't affect execution ⇒ removal is trivially sound. Every output is
wasm-tools validate-checked (in-code + tests) and the WIT round-trip (wasm-tools component wit) still resolves. 5 new tests + fullcargo test --releaseworkspace suite green. fmt clean.Honest results / limits
calc.component.wasm442→235 (−47%),simple.component.wasm261→100 (−62%). These are small — the percentages are not representative of large real-world components.calculator/datetime/hello_rust_hostfixtures cited in Make components small: custom-section GC + component-level reachability GC + canon seam dissolution #239 are not in the repo, so the big-component win is not measured here. Expectation: component-level custom sections are usually small; the 2.3MB bulk is core-module code + DWARF, and fix(242): remap name section + drop .debug_* on function renumber (stop debug-info misattribution) #244 already strips core.debug_*. So Phase A's standalone win on real components is likely modest — the substantial size lever is Phase B (component reachability GC).Not a big-bang size win on its own; it's the safe, correct first slice of #239 with the size-attribution tooling in place. Phase B is where the bytes are.