Open ShuyaoJiang opened 10 months ago
Hi @ShuyaoJiang, thank you for filing this and the other performance issues, much appreciated!
Would it be possible to also share (for this and the other issues you filed) the exact commands you used to compile the code, and also to execute the resulting .wasm
file in all of the runtimes? That'd greatly help us in investigating what's going on.
Hi, here are the commands I used:
emcc -O2 -s WASM=1 -s TOTAL_MEMORY=512MB -I/home/ubuntu/csmith/include <C_PROGRAM> -o <WASM_TARGET>
WasmEdge
and WAMR
/home/ubuntu/.wasmedge/bin/wasmedgec <WASM_TARGET> <WASMEDGE_AOT_TARGET(.wasm)>
/home/ubuntu/wasm-micro-runtime/wamr-compiler/build/wamrc -o <WAMR_AOT_TARGET(.aot)> <WASM_TARGET>
.wasm
file (the execution time is collected in this phase)/home/ubuntu/.wasmtime/bin/wasmtime <WASM_TARGET>
/home/ubuntu/.wasmer/bin/wasmer run <WASM_TARGET>
/home/ubuntu/.wasmedge/bin/wasmedge <WASMEDGE_AOT_TARGET(.wasm)>
/home/ubuntu/wasm-micro-runtime/product-mini/platforms/linux/build/iwasm <WAMR_AOT_TARGET(.aot)> <WASM_TARGET>
This is measuring compilation time as well, you can separate the phases via
$ wasmtime compile foo.wasm
$ wasmtime run --allow-precompiled foo.cwasm
When you separate the compilation and execution phases are you still seeing Wasmtime as 10x slower?
Ok I've dug into this in the same manner as https://github.com/bytecodealliance/wasmtime/issues/7732#issuecomment-1909132554 and I've at least locally confirmed that v8 takes ~2ms to execute this file and Wasmtime takes ~350us. In that sense I suspect that the 100ms+ times reported in the OP were probably including the compilation time for the module.
I'm hesitant to go ahead and close this to ensure you can confirm that when separating out the compilation phase you get expected timings, however.
Summary
Hi, I ran the attached case (C program, compiled to Wasm by
Emscripten
) in different Wasm runtimes, and found abnormal performance inWasmtime
compared with other runtimes. The execution time of this case (time interval from the start to the end of the execution of Wasm bytecode running command) on different runtimes is as follows:We found that in most other test cases, Wasmtime can achieve similar performance (1-2x) with the other two runtimes. However, in this case, Wasmtime is about 10x slower than the other two runtimes.
Emscripten
Wasm Runtime Version
Hardware & OS
Additional details
The attached source program is synthesized by a Csmith seed and a code snippet from another program. The inserted code snippet is on lines
2386-2388
of the source program, which is an increment operation in nested loops. So, we think that this abnormal performance may be caused by this operation. Could you please check this situation? Thank you!1702317926850.zip