-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm speed are no faster than js #558
Comments
Thanks for the report! Always a good idea to keep a close eye on performance. One thing I'd recommend initially is that the default template optimizes for code size, but in your use case it looks like you're optimizing for speed. This difference has historically caused significant slowdown, so I'd recommend deleting that Once I made that change and ran the benchmarks myself locally in Firefox Nightly on a mac I got:
which I think shows a significant improvement across the board from when I was looking at It still shows that wasm isn't so great at fannkuch with respect to the JS implementation. Taking a look at a profile in Gecko it doesn't look like anything is too awry, it may just be a missing optimization in either LLVM or the wasm engine itself. I'm not too familiar with the various engines here, but I'll try passing this along to some Gecko folks to see if they have ideas about optimizations |
Alex, Thanks for looking into it. Your method works. With opt-level=3 and lto=true, binary size went from 810377 to 868998. Not much increase in size I think. It would be nice if rustwasm book have a Optimize for speed section to make it clear, in case people don't understand. If speed of wasm is not fast, why would people use it? : ) |
A good point! I've opened up rustwasm/book#154 to track that for addition to the book itself. With that I think this issue is largely solved, so I'm going to close this. |
🐛 Bug description
I did some algorithm performance comparision with js, but wasm built are no faster than js.
Same nqueen algorithm, wasm version took 4450 ms, js version took 4633ms.
rust native version only took round 2sec.
There's some other algorithm I took from https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/rust.html.
wasm fannkuch: 5579ms
js fannkuch: 4322ms
🤔 Expected Behavior
wasm should be faster than js version
👟 Steps to reproduce
git clone https://github.com/gliheng/wasm-perf
cd wasm-perf
wasm-pack build wasm --release
npm install
npm run dev
Open http://localhost:8080, see the console print
🌍 Your environment
Include the relevant details of your environment.
wasm-pack version: 0.6.0
rustc version: 1.32.0 (9fda7c223 2019-01-16)
The text was updated successfully, but these errors were encountered: