Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Let Binaryen encode our memory init more efficiently #2975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
geraintluff wants to merge 3 commits into AssemblyScript:main
base: main
Choose a base branch
Loading
from geraintluff:combineMemorySegments

Conversation

@geraintluff
Copy link

@geraintluff geraintluff commented Jan 14, 2026
edited
Loading

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

Copy link
Author

geraintluff commented Jan 14, 2026
edited
Loading

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
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?

Copy link
Author

@dcodeIO This doesn't change the memory layout at all, only how it's serialised into WASM/WAT.

The title is probably misleading, sorry! Here's an example of the issue - it will take less space to serialise those as a single block of 01円00円01円01円01円 (note the inserted zero), instead of four separate (data ...)s.

@geraintluff geraintluff changed the title (削除) feat: Let Binaryen pack our data more efficiently (削除ここまで) (追記) feat: Let Binaryen encode our memory init more efficiently (追記ここまで) Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /