WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly
Apache License 2.0
7.39k stars 726 forks source link

wasm (even with -O3) is too slow compared to native #1070

Open appetizermonster opened 7 years ago

appetizermonster commented 7 years ago

I'm building a Web Application using WebAssembly. but it's too slow on Chrome 59,and latest Firefox, different with my expectation. Someone says asmjs is faster than WebAssembly until now. Is there any ways to improve the performance of my WebAssembly program?

kripken commented 7 years ago

Usually code is around half as fast as native, or better, but some things are currently much slower, like C++ exceptions and SIMD. If the code uses those features, that could be the reason.

You can use browser profilers to see what is slow, maybe it will show something.

And if you can create a benchmark showing the issue, please share it here.

appetizermonster commented 7 years ago

Thanks for the advice Could you explain how to profile the compiled WebAssembly with browsers? I couldn't find a way to profile it. I only can see "wasm-function[xxx]" on the JavaScript Profiler in Chrome and Firefox even with the -g, --profiling options. There is no docs describes how to profile WebAssembly.

kripken commented 7 years ago

The wasm-function problem is because wasm changed the names section format. That should be fixed on firefox nightly and beta, but is still a bug in release.

mkb2091 commented 4 years ago

I've also had that issue, but I found adding -g to arguments to wasm-opt results in the profile including the original function name.