Skip to content

Conversation

@geraintluff
Copy link

@geraintluff geraintluff commented Jan 14, 2026

AssemblyScript produces a bunch of small data chunks. Binaryen can split up large chunks to represent them in a compact way, but not combine them.

This change checks whether Binaryen will be doing any optimisation at all, and combines all the MemorySegments into one big segment.

Here's a comparison of the bootstrapped AssemblyScript compiler itself, with and without the change:

file bootstrap size (before) bootstrap size (with changes) delta
assemblyscript.debug.wasm 1783641 1785335 +0.10%
assemblyscript.debug.wasm.gz 379084 379560 +0.13%
assemblyscript.release.wasm 918047 916063 -0.22%
assemblyscript.release.wasm.gz 224686 223556 -0.50%

Since this patch adds functionality, it increases the code size of the debug build, but the release build is still smaller due to the repacking.

It's a small improvement, and on my other projects I'm only seeing a ~1% change but 🤷.

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@geraintluff
Copy link
Author

geraintluff commented Jan 14, 2026

Oh, and obviously it fails a bunch of release-build fixture tests, because it's packing the data differently. 😅

@geraintluff geraintluff changed the title Improvement: let Binaryen pack our data more efficiently feat: Let Binaryen pack our data more efficiently Jan 14, 2026
@dcodeIO
Copy link
Member

dcodeIO commented Jan 14, 2026

Won't this essentially compress alignment away, say for example when we want 4-byte alignment for reasonably performant 32-bit memory accesses?

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.

2 participants