-
Notifications
You must be signed in to change notification settings - Fork 2.7k
WASM runtime API calls on Windows are very expensive #11275
Comments
You've checked if wasmtime alone exhibits this problem? |
Just ran wasmtime benches on Linux and Windows (VM on the same machine, but should be close due to hardware acceleration). Linux:
Windows:
I can see Windows almost always slower, with However this doesn't explain the difference between 20 and 350 blocks/s fully where the difference is much more severe than in benches. |
Do you compile it natively for Windows or do you use the Linux Subsystem under Windows? |
Natively, |
And with the Linux Subsystem? Point here being we don't really support Windows. So, we will not prevent you to fix it and we can merge it, but there will not be that much help from our side. |
For our use case (we're wrapping Substrate-based node into GUI desktop application among other things) WSL is not an option, so I'll not bother trying that.
Fair, we'll have to fix that for sure, I'd be thankful for any pointers or things to look into first if possible. |
I think @koute can you help here. I think he has some benchmarks for the wasm initialization etc. |
@nazar-pc This is somewhat to be expected. My guess would be (I haven't actually profiled this on Windows, so it's just a guess) that the slowness you're seeing is a side effect of how we currently clear the memory between instantiations. On Linux we use Could you try running the code from this PR and see how's the performance? #11232 |
I need to wait a bit for longer sync to kick in and print numbers, but it seems like #11232 makes it A LOT faster on Windows, should be on the same order of magnitude as Linux 🔥 How close is it to landing? I see it is already reviewed. |
Yeah, #11232 should be updated as such that closes this issue. |
That's good to know! I didn't expect it to improve the performance on Windows, but I forgot that we were doing a Yeah, it's almost done. It still needs one more review and then it should be good to go. |
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
We discovered in subspace/subspace#307 that sync on Windows is extremely slow. I did some initial testing and discovered that every runtime API call on Windows takes ~5ms, resulting in sync speed of under 20 blocks/s with our chain, while under Linux I can sync with 500 blocks/s speed.
Not sure what the root cause is yet, but it is a UX issue for our chain and it seems to originate from Substrate, hence this issue.
UPD: With native runtime sync on Windows increases to ~350 blocks/s, runtime call cost vanished.
Steps to reproduce
https://github.com/subspace/subspace/blob/main/docs/farming.md can be used to run pre-built Windows binaries of our chain and see sync speed, it also has instructions for building from source in case you want to add instrumentation and recompile. I guess building any other chain for Windows will result in similar sync slowness.
The text was updated successfully, but these errors were encountered: