ruby.wasm icon indicating copy to clipboard operation
ruby.wasm copied to clipboard

Make wasm-opt faster for Asyncifying CRuby

Open kateinoigakukun opened this issue 2 years ago • 1 comments

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

kateinoigakukun avatar May 20 '23 07:05 kateinoigakukun

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

kateinoigakukun avatar May 20 '23 18:05 kateinoigakukun