Stream: git-wasmtime

Topic: wasmtime / issue #6353 Component loading performance issue


view this post on Zulip Wasmtime GitHub notifications bot (May 08 2023 at 19:11):

Mossaka opened issue #6353:

It takes 20 seconds to load a component in wasmtime 7.0.0. It is definitely much slower than loading a wasm module of comparable size. Is this expected? What could be the cause?

wasm component file size: 6.9M

let start = Instant::now();
let component = Component::from_file(&engine, &input).unwrap();
let elapsed = start.elapsed();
println!("Time to load: {:?}", elapsed);

Time to load: 20.891809886s

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2023 at 19:25):

alexcrichton commented on issue #6353:

Definitely unexpected! Do you have a component you could share to reproduce with?

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2023 at 20:24):

Mossaka commented on issue #6353:

I do. If you clone down this repo, and then do

make install-js
make build-js

You will get a component called js.component.wasm.

You can run with cargo run --js.component.wasm

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2023 at 21:42):

alexcrichton commented on issue #6353:

Sorry won't get a chance to dig into this today, but from what you pasted I think --release is missing? Otherwise that's building in debug mode and it's known that debug mode is much slower than release for Cranelift.

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 14:55):

alexcrichton commented on issue #6353:

Testing locally my guess is that this is --release-vs-not. Your command above, cargo run --js.component.wasm, is not a valid invocation of Cargo however since it thinks --js.component.wasm is an argument. Given that I'm not sure what you meant to paste there, so I'm not sure if for you it'l lbe --release-vs-not.

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 18:19):

Mossaka commented on issue #6353:

Ah yes thanks so much! The issue is indeed that I didn't pass --release.

With release mode, the time to load the component is 1.2s. Will close this issue.

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 18:19):

Mossaka closed issue #6353:

It takes 20 seconds to load a component in wasmtime 7.0.0. It is definitely much slower than loading a wasm module of comparable size. Is this expected? What could be the cause?

wasm component file size: 6.9M

let start = Instant::now();
let component = Component::from_file(&engine, &input).unwrap();
let elapsed = start.elapsed();
println!("Time to load: {:?}", elapsed);

Time to load: 20.891809886s

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 18:20):

Mossaka reopened issue #6353:

It takes 20 seconds to load a component in wasmtime 7.0.0. It is definitely much slower than loading a wasm module of comparable size. Is this expected? What could be the cause?

wasm component file size: 6.9M

let start = Instant::now();
let component = Component::from_file(&engine, &input).unwrap();
let elapsed = start.elapsed();
println!("Time to load: {:?}", elapsed);

Time to load: 20.891809886s

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 18:21):

Mossaka commented on issue #6353:

Actually, I also tried to load a rust-produced wasm component with 2.0M size. The loading time is 20ms, which is, suprisingly, significantly faster than the js component. Is this expected?

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 18:22):

Mossaka commented on issue #6353:

  ./target/release/wit-bindgen-go-template js.component.wasm
Time to load: 1.200816367s

  ./target/release/wit-bindgen-go-template rust.component.wasm
Time to load: 20.610888ms

  ls rust.component.wasm
rust.component.wasm
  l rust.component.wasm
.rwxrwxr-x 2.0Mi mossaka  2 May 22:10 -I rust.component.wasm*
  l js.component.wasm
.rw-rw-r-- 6.5Mi mossaka  8 May 19:06 -I js.component.wasm

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 18:23):

Mossaka edited a comment on issue #6353:

  ./target/release/wit-bindgen-go-template js.component.wasm
Time to load: 1.200816367s

  ./target/release/wit-bindgen-go-template rust.component.wasm
Time to load: 20.610888ms

  l rust.component.wasm
.rwxrwxr-x 2.0Mi mossaka  2 May 22:10 -I rust.component.wasm*

  l js.component.wasm
.rw-rw-r-- 6.5Mi mossaka  8 May 19:06 -I js.component.wasm

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 19:51):

alexcrichton commented on issue #6353:

Can you upload the {js,rust}.component.wasm binaries here as well? In general though yes it's probalby the case that JS is going to be longer to compile than Rust since JS has all of spidermonkey or some other JS engine

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 21:00):

Mossaka commented on issue #6353:

Unfortunately I was not able to upload a *.wasm file here because it's not a supported file type.

view this post on Zulip Wasmtime GitHub notifications bot (May 09 2023 at 22:12):

alexcrichton commented on issue #6353:

Ah right, yes, but you can gzip the components and upload them. (or maybe even rename it to foo.gz and upload it, I don't think the check is that restrictive)

view this post on Zulip Wasmtime GitHub notifications bot (May 10 2023 at 11:40):

tschneidereit commented on issue #6353:

I'd bet that the Rust component includes debug info, and that the code section is actually much smaller, and hence faster to compile

view this post on Zulip Wasmtime GitHub notifications bot (May 19 2023 at 00:38):

Mossaka commented on issue #6353:

js.component.wasm.gz
rust.component.wasm.gz

view this post on Zulip Wasmtime GitHub notifications bot (May 19 2023 at 00:38):

Mossaka edited a comment on issue #6353:

Sorry for getting back to you late. Here are the gz files

js.component.wasm.gz
rust.component.wasm.gz

view this post on Zulip Wasmtime GitHub notifications bot (May 19 2023 at 14:22):

alexcrichton commented on issue #6353:

Ok yes I can confirm that the compile times are effectively as expected. The Rust component is almost entirely debug information which can be stripped out with wasm-tools strip, where the JS component is almost entirely code (it is spidermonkey after all).

Given that I'm going to close this as expected where --release definitely should be enabled for Cranelift and the compilation pipeline, and it's expected that a JS component compiles more slowly than a Rust component.

view this post on Zulip Wasmtime GitHub notifications bot (May 19 2023 at 14:23):

alexcrichton closed issue #6353:

It takes 20 seconds to load a component in wasmtime 7.0.0. It is definitely much slower than loading a wasm module of comparable size. Is this expected? What could be the cause?

wasm component file size: 6.9M

let start = Instant::now();
let component = Component::from_file(&engine, &input).unwrap();
let elapsed = start.elapsed();
println!("Time to load: {:?}", elapsed);

Time to load: 20.891809886s


Last updated: Dec 23 2024 at 12:05 UTC