Skip to content
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

Rust + WASM vs JS performance #169

Open
helabenkhalfallah opened this issue Jul 19, 2020 · 2 comments
Open

Rust + WASM vs JS performance #169

helabenkhalfallah opened this issue Jul 19, 2020 · 2 comments
Labels
question Further information is requested

Comments

@helabenkhalfallah
Copy link

Summary

Hello, I want to use WASM in my frontend projects but comparing Rust + WASM performance vs JS, I always get JS more faster :

My project :
https://github.com/helabenkhalfallah/rust-react-wasm-js

I tried also many optimization flags combination, like :

[profile.release]
# This makes the compiled code faster and smaller, but it makes compiling slower,
# so it's only enabled in release mode.
lto = true

[profile.dev]
lto = true
opt-level = 3

Benchmarks :
1- Filter a big array to keep only numbers (4000 records)
2- Sort, map, filter a big array (about 10000 records)
3- Rust + reqwest vs JS + axios (download about 7800 records)

Benchmarks results :
image

WASM isn't suitable for these kinds of tasks (usual website tasks) ? If yes where WASM + Rust shine (I'm confused about when to use?)
Else is there others suggestions for optimization ?

Thanks :)

@helabenkhalfallah helabenkhalfallah added the question Further information is requested label Jul 19, 2020
@helabenkhalfallah
Copy link
Author

Hello, have you any suggestions how can I enhance performance and reduce bundle size ? Why Rust + Wasm are slower than JS, is this due to memory read/write and wasm boot time ? Could you help me to go further more in my tests and adoption. Thanks.

@alucardpj
Copy link

this problem maybe due to WasmPackPlugin,this plugin will build the wasm in debug mode by default, until you set the

forceMode: "production"

explicitly. If you directly run "wasm-pack build", it will build in production mode, so there is a huge gap between these two testing result. You can turn this setting and have a try.
This bug bothered me whole day. WTF!
Hope it can help you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants