bytecodealliance / bytecodealliance/wasmtime

The `__deregister_frame` is slow on macos

Open
#6,541 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

We have a precompiled wasm module of about 337,2MB that if dropped the `UnwindRegistration::drop` takes around ~22 secs (can quite vary) to finish. Sometimes it takes over 100 seconds. I did some benchmarking and we have 266664 unwind registers and the time per frame deregister is for me around 0.0843227 ms.

This dropping happens when a `wasmtime::Module` drops.

Three runs:

```
Deregister 266664 frames in 22485 ms (84.3227 microsec/frame)
Deregister 266664 frames in 22448 ms (84.1817 microsec/frame)
Deregister 266664 frames in 22232 ms (83.3742 microsec/frame)
```

A fast deregister/register time is vital to us. When hot-reloading after cargo watch detects a change when a single code line changes it used to take 2 secs, but somewhere in last few months, this has somehow gotten very slow. Is there an easy solution here or a solution?

This can be very easy reproduced:

```
#[test]
fn deserialize_test_memory() {
let engine = Engine::new(&Config::new().epoch_interruption(true)).unwrap();

let path = "path-to-precomipled-bytes";

unsafe {
let deserialized: wasmtime::Module = Module::deserialize_file(&engine, path).unwrap();

let time = Instant::now();
println!("Dropping module...");
drop(deserialized);
println!("Dropped module {:?}", time.elapsed());
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.