deislabs / containerd-wasm-shims

containerd shims for running WebAssembly workloads in Kubernetes
Apache License 2.0
312 stars 48 forks source link

Potential improvement to compilation size on rust spin image #57

Closed AtlasHands closed 1 year ago

AtlasHands commented 1 year ago

If the rust spin image is compiled with symbol stripping the size can be decreased from 1.9MB to 132KB, using the command:

RUSTFLAGS='-C link-arg=-s' cargo build --target wasm32-wasi --release

this can also be done in the Cargo.toml file so that compiling in release mode strips symbols by default:

[profile.release]
strip = true

I tested to make sure it would work with the spin framework using spin up and it was functional.

Mossaka commented 1 year ago

Thanks! I like it a lot. That's an interesting idea.

Mossaka commented 1 year ago

It seems that using cargo wasi build --release together with strip=true further reduces the size of the wasm binary. This is probably due to the fact that cargo wasi uses wasm-opt by default.

Mossaka commented 1 year ago

Closed by #59