Skip to content

opt(#239 Phase A): component custom-section GC (producers/name/.debug_*, opt-in component-type)#253

Open
avrabe wants to merge 1 commit into
mainfrom
feat/239-phase-a-custom-section-gc
Open

opt(#239 Phase A): component custom-section GC (producers/name/.debug_*, opt-in component-type)#253
avrabe wants to merge 1 commit into
mainfrom
feat/239-phase-a-custom-section-gc

Conversation

@avrabe

@avrabe avrabe commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Refs #239 (Phase A of 3). Strips semantically-inert custom sections from components — the component-level layer that component_optimizer.rs never touched.

What

  • Strip 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-component introspection depends on it); stripped only behind opt-in --strip-component-type.
  • Extends fix(242): remap name section + drop .debug_* on function renumber (stop debug-info misattribution) #244's core-module strip to also drop name/producers on the component's nested-core-module path (strip_inert_module_sections).
  • CLI size breakdown (core code vs component types vs custom stripped, before→after).

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 + full cargo test --release workspace suite green. fmt clean.

Honest results / limits

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant