jameysharp opened PR #8802 from jameysharp:profile-hostcalls
to bytecodealliance:main
:
Otherwise it's difficult to interpret the profiles because whatever happened to be the last sample before the hostcall appears to be taking the entire time of the hostcall.
Ideally we'd do more to highlight which hostcall is running or use markers to delimit the boundaries of each hostcall, but this should be a good starting point.
I haven't tested this at all yet, just wanted to share it as something to point to for folks who are pushing the current limits of the guest profiler.
jameysharp updated PR #8802.
jameysharp updated PR #8802.
jameysharp edited PR #8802:
The output of the guest profiler can be misleading around hostcalls. Whatever happened to be the last sample before the hostcall appears to run for the entire time of the hostcall. This change ensures that we can see the actual call stack at the time of the hostcall, and get a visual indication of which periods are not spent executing guest code.
jameysharp commented on PR #8802:
@alexcrichton, this PR means that the guest profiler will require the new
call-hook
feature. How do you think we should set the defaults for these features?I could imagine for example that
profiling
andcall-hook
would both be off-by-default in thewasmtime
crate so that embedders don't take the performance hit unless they ask for it, but enabled by default inwasmtime-cli
so that CLI users have the full profiler available.Alternatively, the profiler's use of call-hooks could be made conditional on whether
call-hook
is enabled, but 1) I think that's going to be a bit ugly and 2) the new functionality makes the profiles quite a bit easier to interpret correctly so I kind of want it always available.
jameysharp has marked PR #8802 as ready for review.
jameysharp requested pchickey for a review on PR #8802.
jameysharp requested wasmtime-core-reviewers for a review on PR #8802.
alexcrichton commented on PR #8802:
Is the use case you're primarily interested in the CLI itself? If so could we thread that needle by making the hooks conditional but unconditionally enabling them in the CLI?
jameysharp commented on PR #8802:
I do want this available in the CLI but I also want it in Fastly's CLI embedding of Wasmtime (Viceroy). So as long as all embedders have the option to turn this on then I'm happy.
I'll push a commit for that in a bit.
fitzgen commented on PR #8802:
Can we make it so that the sample-at-hostcall functionality only happens when the call hook feature is enabled and then embeddings can enable or disable the feature to get more functionality (at the cost of some host-wasm call overhead) as they choose?
jameysharp commented on PR #8802:
I just realized that the
CallHook
type (the enum indicating which kind of transition happened) is not guarded by thecall-hook
feature, which makes this simpler than I expected. That means the part of the guest profiler that's in the wasmtime crate does not actually require thecall-hook
feature; it can unconditionally provide acall_hook
method for an embedder to use if they want to.The embedder is responsible for arranging for that function to be called from an actual call-hook, and so it's their responsibility to enable the
call-hook
feature if they want to use that part of the guest profiler. In principle I think an embedder could also use other means to pass the same information to the profiler if they wanted to.Hopefully that makes everyone happy?
alexcrichton commented on PR #8802:
Oh nice! That sounds good to me :+1:
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Stray submodule change?
jameysharp submitted PR review.
jameysharp created PR review comment:
Ah dang, thanks for catching that!
jameysharp requested wasmtime-default-reviewers for a review on PR #8802.
jameysharp updated PR #8802.
jameysharp merged PR #8802.
Last updated: Dec 23 2024 at 13:07 UTC