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

Performance problem while executing the given wasm file #751

Closed
luxinyi0105 opened this issue Aug 7, 2023 · 7 comments
Closed

Performance problem while executing the given wasm file #751

luxinyi0105 opened this issue Aug 7, 2023 · 7 comments

Comments

@luxinyi0105
Copy link

Description

Wasmi maybe have performance problems while executing the given wasm file.

Versions and Environment

Tools version: wasmi_cli 0.30.0
Operating system: Ubuntu 22.04.1
Architecture: x86_64

Current State

$ wasmi_cli mutated.wasm

It will take about 1 hour to output the correct checksum result checksum = 93DF9E88

Expected

$ wasmi_cli mutated.wasm
checksum = 93DF9E88

Extra Info

The current execution result of wasmi is correct, but it will take about 1 hour, far exceeding the time required to execute other wasm files. At the same time, using other WebAssembly runtimes, such as wasmer and wasmtime, to execute the same wasm file will take no more than 1 minute to obtain the correct execution results. Therefore, I believe that there may be performance related problems in wasmi, which may slow down the execution speed of the given testcase.

@Robbepop
Copy link
Member

Robbepop commented Aug 7, 2023

Can you please try to run the Wasm file using other interpreter based Wasm runtimes? E.g. Wasm3, WAMR classic or fast interpreter, toywasm or Wasmedge interpreter.

Generally interpreters are orders of magnitude slower in execution compared to JIT compiled runtimes.

The most recent wasmi version is 0.31.0 and has an important optimization for f64 values if those are used frequently in your Wasm blob.

@luxinyi0105
Copy link
Author

Can you please try to run the Wasm file using other interpreter based Wasm runtimes? E.g. Wasm3, WAMR classic or fast interpreter, toywasm or Wasmedge interpreter.

Generally interpreters are orders of magnitude slower in execution compared to JIT compiled runtimes.

The most recent wasmi version is 0.31.0 and has an important optimization for f64 values if those are used frequently in your Wasm blob.

Thanks for your reply. Actually I have tried to use some of the runtimes you mentioned to execute the same wasm file. For Wasm3, it takes about 3 minutes to output the correct checksum result, and for WasmEdge, it takes about 10 minutes with its interpreter mode.

According to your suggestion, I installed the latest version 0.31.0, executed again, and record the time. The result is 46 minutes.

Compared to other interpreter based WASM Runtimes I have used, this time is still relatively long. As for if Wasmi really has performance related problems while executing the given wasm file, it still requires you to determine. Thanks a lot.

@Robbepop
Copy link
Member

Robbepop commented Aug 8, 2023

Can you please try to run the Wasm file using other interpreter based Wasm runtimes? E.g. Wasm3, WAMR classic or fast interpreter, toywasm or Wasmedge interpreter.
Generally interpreters are orders of magnitude slower in execution compared to JIT compiled runtimes.
The most recent wasmi version is 0.31.0 and has an important optimization for f64 values if those are used frequently in your Wasm blob.

Thanks for your reply. Actually I have tried to use some of the runtimes you mentioned to execute the same wasm file. For Wasm3, it takes about 3 minutes to output the correct checksum result, and for WasmEdge, it takes about 10 minutes with its interpreter mode.

According to your suggestion, I installed the latest version 0.31.0, executed again, and record the time. The result is 46 minutes.

Compared to other interpreter based WASM Runtimes I have used, this time is still relatively long. As for if Wasmi really has performance related problems while executing the given wasm file, it still requires you to determine. Thanks a lot.

If Wasm3 took 3 minutes then it should take wasmi between 6-9 minutes usually since wasmi is roughly 2-3 times slower compared to Wasm3. I will take a look into what is going wrong there. Thanks a lot for the testcase!

One possibility is that you installed wasmi incorrectly and it doesn use its full optimization potential. Have you installed wasmi via cargo install wasmi? If you installed wasmi manually please do so via cargo build --profile bench since cargo build --release won't apply all needed optimizations.

@luxinyi0105
Copy link
Author

@Robbepop
You are right. The executing time has been significantly reduced when use cargo build --profile bench. So the problem has been resolved. Thanks again!

@Robbepop
Copy link
Member

Robbepop commented Aug 8, 2023

@Robbepop You are right. The executing time has been significantly reduced when use cargo build --profile bench. So the problem has been resolved. Thanks again!

Glad to hear. Can you tell me about the exact times please? :)

@luxinyi0105
Copy link
Author

@Robbepop You are right. The executing time has been significantly reduced when use cargo build --profile bench. So the problem has been resolved. Thanks again!

Glad to hear. Can you tell me about the exact times please? :)

It takes about 1 m 16 s.

@Robbepop
Copy link
Member

Robbepop commented Aug 8, 2023

Thanks! Oh wow that's quite some improvement. :D

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

No branches or pull requests

2 participants