Stream: general

Topic: Wasmtime runs faster than rust native code


view this post on Zulip Hoping White (Jul 25 2024 at 01:39):

I am writing a new framework that can extend the Unity game engine to use Rust and Wasm. I am testing the ECS with specs crate. I am amazed to find that wasm32-unknown-unknwon with wasmtime runs faster than x86_64-pc-windows-msvc. I tried to change the profile.release.opt-level, there are no good news. The default setting is better. Any explanation about this?

view this post on Zulip Soni L. (Jul 25 2024 at 03:10):

32-bit memory, same way x32 is often faster than x64 (see https://en.wikipedia.org/wiki/X32_ABI )

view this post on Zulip Hoping White (Jul 25 2024 at 04:28):

Soni L. said:

32-bit memory, same way x32 is often faster than x64 (see https://en.wikipedia.org/wiki/X32_ABI )

If this is true, I should observe that target i686-pc-windows-msvc is faster than x86_64-pc-windows-msvc, but it is not.
The result is i686 fps is 370, x86_64 fps is 410.

view this post on Zulip Jacob Lifshay (Jul 25 2024 at 05:40):

Hoping White said:

If this is true, I should observe that target i686-pc-windows-msvc is faster than x86_64-pc-windows-msvc, but it is not.
The result is i686 fps is 370, x86_64 fps is 410.

that's because i686 has a bunch of other things that make it slower, such as fewer registers, a terrible calling convention (passes all arguments in memory by default), no built-in pc-relative addressing, etc.

view this post on Zulip Hoping White (Jul 25 2024 at 06:14):

The best results during testing were with the 181.mcf SPEC CPU 2000 benchmark, in which the x32 ABI version was 40% faster than the x86-64 version.

This data is quite close to my test results, my test results are 130FPS for wasm32, and around 100FPS for x86_64. Thank you all for the explanation.


Last updated: Nov 22 2024 at 17:03 UTC