bytecodealliance / bytecodealliance/wasmtime
Add guest-profiler markers around host-calls
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
#### Feature
The Firefox profiler format supports annotating timestamps or time-ranges with "markers", to show particular events on the same timeline as the profile. We could use markers in the guest profiler to indicate when profiling was suspended due to running a host-call.
#### Benefit
The guest profiler specifically only profiles WebAssembly guest code, so any time spent in host-calls is just absent from the profile. We'd present a more complete picture by marking those intervals so the user can see where host-calls happened, how long they took, and ideally what host-call was issued.
#### Implementation
As a starting point, Wasmtime's [`Store::call_hook`](https://docs.rs/wasmtime/latest/wasmtime/struct.Store.html#method.call_hook), or its async variant, allows registering a callback for both exit from and entry to the guest. I don't think we can find out _what_ host-call triggered the exit that way, though.
Also we don't get a reference to the `Store` in the callback, so we can't sample the stack at that point. That might be an oversight in the call-hook API.
#### Alternatives
The profiler is usable without these markers. A long-running host-call just appears as a gap in the profile's timeline.
We might be able to do something with the `Linker` to wrap all the configured host-calls, rather than using the `call_hook`. That should at least allow us to record which host-call triggered each exit.
Contributor guide
Assessment
This issue has not been assessed yet.