Stream: wasmtime

Topic: ✔ Minimising the size of wasmtime executable?


view this post on Zulip Mats Brorsson (Oct 24 2023 at 09:29):

I met a person at Wasm research day in Munich (I never registered the name, sorry) who told me that it should be possible to reduce the size of the CLI executable significantly. When compiling it straight out of the box (repo) with --release the executable is about 50 MB. With the following options in Cargo.toml:

[profile.release]
strip = true  # Automatically strip symbols from the binary.
opt-level = "z"  # Optimize for size.
lto = true

I can get it down to 19 MB.

The question is: is it possible to reduce it further without hurting performance? I'd like to avoid dynamically linked libraries.

view this post on Zulip Jeff Parsons (Oct 24 2023 at 11:03):

I think this is what you're looking for: https://github.com/bytecodealliance/wasmtime/pull/7282 There have also been some follow-up PRs, but I think everything else should be discoverable from this.

This PR is borne out of discussions from last week's CG meetings about the suitability of Wasmtime in embedded scenarios. One of the primary concerns that arose was the binary size of the Wasmtime ...

view this post on Zulip Alex Crichton (Oct 24 2023 at 14:15):

Documentation for producing a minimal build is now here and example release artifacts are here as wasmtime-min executables inside of each CLI tarball. Currently this is ~2M, and depending on your use case that can be smaller too even.

If you've got size concerns still please let us know as it's something we'd like to be aware of!

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip Ralph (Oct 25 2023 at 12:55):

what is this evil?

view this post on Zulip Chris Fallin (Oct 25 2023 at 16:20):

@Alex Crichton if you can get it down to 1.44MB, I will celebrate by purchasing some retro floppies and a floppy drive and creating the first ever Wasmtime Installation Disk

view this post on Zulip Till Schneidereit (Oct 25 2023 at 16:42):

why stop there? I say 720kb or bust!

view this post on Zulip Ralph (Oct 25 2023 at 17:03):

No one should ever need more than 720kb... wait.

view this post on Zulip Lann Martin (Oct 25 2023 at 17:10):

This is just a curiosity for me so no pressure to do anything about it but I don't see artifacts at the link; were they replaced by CI?

view this post on Zulip Ralph (Oct 25 2023 at 17:13):

I found them inside the .xz files -- two different executables

view this post on Zulip Alex Crichton (Oct 25 2023 at 17:14):

Yeah the new "min" artifacts are in the normal tarballs as the wasmtime-min executable or the libwasmtime-min.so dynamic library (or libwasmtime-min.a)

view this post on Zulip Ralph (Oct 25 2023 at 17:15):

squillace@idiopath:~$ ./wasmtime-min
error: one or more required arguments were not provided

view this post on Zulip Alex Crichton (Oct 25 2023 at 17:15):

heh part of being "min" is compiling out all the help text :)

view this post on Zulip Ralph (Oct 25 2023 at 17:15):

args the same?

view this post on Zulip Ralph (Oct 25 2023 at 17:16):

can I use wasmtime as a guide to wasmtime-min?

view this post on Zulip Alex Crichton (Oct 25 2023 at 17:16):

yes, or at least that's the intention!

view this post on Zulip Ralph (Oct 25 2023 at 17:16):

np!!!

view this post on Zulip Alex Crichton (Oct 25 2023 at 17:16):

you can only feed in *.cwasm into wasmtime-min, but you can create the *.cwasm with wasmtime

view this post on Zulip Ralph (Oct 25 2023 at 17:16):

right

view this post on Zulip Lann Martin (Oct 25 2023 at 17:22):

For your 720K floppy: wasmtime-min.xz 610K :smile:

view this post on Zulip Lann Martin (Oct 25 2023 at 17:26):

(I assume you already have liblzma on your IBM PC Convertible)

view this post on Zulip Till Schneidereit (Oct 25 2023 at 17:27):

as one does

view this post on Zulip Notification Bot (Oct 26 2023 at 08:58):

Mats Brorsson has marked this topic as resolved.


Last updated: Dec 23 2024 at 14:03 UTC