Finschia/cosmwasm

unreachable error running Benchmark test on M1 Mac

Closed this issue · 2 comments

This PR is related to #250

After checking, this problem in the benchmark test was not specific to M1, but was caused by differences in machine performance.
Therefore, the problem is not specific to M1, but can be caused by the performance of Intel machines as well.

Summary

When test is executed, the following error occurs for M1.

$pwd
~/cosmwasm/packages/vm
$cargo bench --no-default-features --features bench -- --color never --save-baseline singlepass
Benchmarking DynamicLink/native_dynamic_link_trampoline with dummy contract_call
Benchmarking DynamicLink/native_dynamic_link_trampoline with dummy contract_call: Warming up for 3.0000 s
Benchmarking DynamicLink/native_dynamic_link_trampoline with dummy contract_call: Collecting 12 samples in estimated 10.000 s (12M iterations)
Benchmarking DynamicLink/native_dynamic_link_trampoline with dummy contract_call: Analyzing
DynamicLink/native_dynamic_link_trampoline with dummy contract_call
                        time:   [839.67 ns 848.11 ns 853.57 ns]
                        change: [-35.259% -26.509% -16.533%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking DynamicLink/native_dynamic_link_trampoline with mock cache environment
Benchmarking DynamicLink/native_dynamic_link_trampoline with mock cache environment: Warming up for 3.0000 s
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RuntimeErr { msg: "Wasmer runtime error: RuntimeError: unreachable" }', packages/vm/benches/main.rs:286:64
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This could be a problem with comswasm, or it could be a problem with INSTANCE_CACHE, a thread-local variable, or elsewhere.

However, when the thread is temporarily stopped by sleep!(), etc., test runs without error even in M1, so the cause may be around INSTANCE_CACHE, a thread-local variable.

Environment

$ rustup --version
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.63.0 (4b91a6ea7 2022-08-08)`
$ sysctl machdep.cpu.brand_string
machdep.cpu.brand_string: Apple M1 Pro

At this time, the team has taken the decision that M1 Mac developers (or those with high-spec PCs) will not benchmark locally. This issue is low priority.

Since INSTANCE_CACHE is no longer used, this problem is also solved.
And this benchmarking test(native_dynamic_link_trampoline with mock cache environment) is also deleated.

via: #294, #295, #296