ruby / ruby.wasm

ruby.wasm is a collection of WebAssembly ports of the CRuby.
https://ruby.github.io/ruby.wasm/
MIT License
666 stars 53 forks source link

Make wasm-opt faster for Asyncifying CRuby #230

Open kateinoigakukun opened 1 year ago

kateinoigakukun commented 1 year ago

Asyncify pass is super slow against CRuby. Let's optimize the Asyncify pass implementation in Binaryen

kateinoigakukun commented 1 year ago

It looks like the main bottleneck is musl's atomic operations. Actually, multithreaded code doesn't contribute the speed at all... Self-built wasm-opt linked with glibc is 5x faster than the prebuilt binary distributed on GitHub Release of binaryen repo.

$ time BINARYEN_CORES=1 wasm-opt-musl --asyncify -O3 -g --pass-arg=asyncify-ignore-imports -o ruby.opt ../ruby.raw
52.08s user 1.60s system 99% cpu 53.726 total

$ time wasm-opt-musl 
--asyncify -O3 -g --pass-arg=asyncify-ignore-imports -o ruby.opt ../ruby.raw;
252.25s user 496.39s system 1321% cpu 56.640 total

$ time wasm-opt-glibc --asyncify -O3 -g --pass-arg=asyncify-ignore-imports -o ruby.opt ../ruby.raw;
73.84s user 0.42s system 747% cpu 9.927 total

ruby.raw.zip