perl: wasm-opt -O2 post-link pass to reclaim ~470 KB (kd-lfas)#833
Conversation
build-perl.sh links with a load-bearing --no-gc-sections and applied no post-link size pass, leaving dead code from the 30 curated static XS extensions. Add a wasm-opt -O2 pass after the interpreter is re-collected and BEFORE install_local_binary applies fork instrumentation. Fork instrumentation hardcodes mutable-global offsets and must run last, so wasm-opt precedes it -- matching bash/git/php/vim. Plain -O2 (not -all) honors the binary's declared target_features; -all introduced exnref locals that break wasm-fork-instrument. Shipped perl.wasm 7,291,919 -> 6,822,373 bytes (-469,546 / -6.44%). ~3.06 MB of the binary is fork-instrumentation overhead, so this reclaims most of the non-instrumentation dead code. Verified on the instrumented recipe output: runtime-smoke 9/9, extended functional battery 21/21, fork/system/pipe smoke pass. -O2 over -Oz (only 0.45% smaller) for interpreter throughput + parity. Bump build.toml revision 2 -> 3 (output bytes change). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…pass SUMMARY.md (measurement table, structural finding, decision), pass/fail/skip outcome lists, and the ext-smoke.ts / fork-smoke.ts harnesses used to verify the optimized binary. Evidence only; the .wasm artifacts are intentionally not committed. fork-smoke.ts is the first fork/system coverage for perl (candidate to promote via kd-gk6o CI wiring). 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.
What
Add a
wasm-opt -O2post-link, pre-fork-instrumentation pass topackages/registry/perl/build-perl.sh; bumpbuild.tomlrevision 2 → 3.build-perl.shlinks with a load-bearing--no-gc-sections(so wasm-ld's--allow-undefineddoesn't strip live Perl code) and applied no post-link sizepass, leaving dead code from the 30 curated static XS extensions.
wasm-opt -O2reclaims it. It runs before
install_local_binary's fork instrumentation,which hardcodes mutable-global offsets and must run last — matching
bash/git/php/vim. Plain
-O2(not-all) honors the binary's declaredtarget_features;-allintroducedexnreflocals that breakwasm-fork-instrument.Size
Shipped
perl.wasm7,291,919 → 6,822,373 bytes (−469,546 / −6.44%).Note: ~3.06 MB of the shipped binary is fork-instrumentation overhead (perl
imports
kernel_fork+kernel_execve), not dead code — so wasm-opt reclaims mostof the remaining non-instrumentation slack.
-Ozwas measured only 0.45%smaller;
-O2chosen for interpreter throughput + convention parity.Verification (on the instrumented recipe output, 6,822,373 B, 5 WPK exports)
unicode/
/u, sort, hashes, pack/unpack, POSIX math, List::Util, refs/closures)open('-|',LIST). Confirms fork instrumentation survives the pass (runtime/ext
smokes never fork).
The perl source compile is unchanged; validated
instrument(raw)==shippedbyte-identical, and exercised the added
wasm-opt -O2+ realinstall_local_binaryglue end-to-end. Full evidence in
test-runs/kd-lfas/SUMMARY.md.Stacking
Stacked on #821 (kd-k7zy, build-perl.sh rev 2). Base is the kd-k7zy branch;
retarget to
mainonce #821 merges. The pass could alternatively be folded into#821 if the maintainer prefers a single perl recipe PR.
Bead: kd-lfas.
🤖 Generated with Claude Code