posborne requested wasmtime-core-reviewers for a review on PR #10507.
posborne requested fitzgen for a review on PR #10507.
posborne opened PR #10507 from posborne:guest-profiling-component-model
to bytecodealliance:main
:
This change adds support for using guest profiling with the component model. In addition to the core change to support attributing stack frames to constituent modules within a component, the cli
run
andserve
commands are also updated to support using the--profile=guest
cli option with components.https://github.com/bytecodealliance/wasmtime/issues/8773
https://github.com/bytecodealliance/wasmtime/issues/7669<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
posborne commented on PR #10507:
Here's a couple samples from some simple components for the CLI and wasi-http. There's a couple frames missing from the CLI example so I think I am missing something from the component that isn't part of
static_modules()
individual functions which I'll try to find.I'm also not at all confident on the API which would be best for all use cases for
GuestProfiler
in terms of how users are likely to want to register various components and modules. Here we support 1 component + multiple additional modules which was biased by the potential registrations in therun
andserve
commands with prelinking but definitely welcome ideas. I considered having aProfileTarget
enum or similar to abstract over things -- some approaches are a bit more challenging due to conditional compilation concerns.wasmtime-run-profile-data.json
wasmtime-serve-profile-data.json
fitzgen submitted PR review:
LGTM modulo a couple nitpicks :+1:
fitzgen created PR review comment:
Nitpick for here and elsewhere: we generally try to capitalize sentences and such in comments.
fitzgen created PR review comment:
"linarly"
fitzgen created PR review comment:
It probably makes sense to use a builder-style API in the limit here, to allow users to specify all the various components and modules they are profiling, but this is totally fine for the moment.
FrankReh submitted PR review.
FrankReh created PR review comment:
Super nits: Is "past this point, ... from this point forward" redundant? Maybe I should understand the context better. Also, while here, I'll point out the title has "suport" in it, probably a typo.
FrankReh commented on PR #10507:
Drive-by comment:
I cloned the branch and was successful in creating a wasmtime-guest-profile.json with it that profiler.firefox.com accepted. The flame graph aspect of that UI didn't seem to work but presumably that has nothing to do with what this PR is accomplishing.
Thanks for making this feature possible!
posborne commented on PR #10507:
@FrankReh thanks for doing a check. In my testing, I was getting the flamegraph to work fine for both
run
andserve
; what was your test setup? Usually when I didn't get flame graphs in the UI it was due to some part of the sampling not working correctly (but I can't discount something else going sideways unrelated to the profile itself).Does the call tree view work?
FrankReh commented on PR #10507:
My bad. Even the flamegraph aspect is working. Embarrassing but I didn't recognize the pane as a valid flamegraph simply because of the grey color and my test case having very little happening besides two function calls writing to stdout repeatedly. In my defense, first time running profiling for a wasm module and first time using profiler.firefox.com web app.
Thanks again for working to get this functionality added.
posborne submitted PR review.
posborne created PR review comment:
Yeah, I noticed that as well when I was making updates. Should be addressed with the fixup.
posborne updated PR #10507.
posborne commented on PR #10507:
My fixups got autosquashed when I rebased to resolve a trivial conflict in
run.rs
but updates were all very minor:
- Couple small updates to hopefully make CI happy with dead_code conditional comp and type annotations from c-api code.
- Updates to comments as suggested (plus a few in other parts of the patch to match the convention.
For now, keeping the API as-is to keep the collateral for this change smaller and (mostly) not require updates for users of the API (may require very minor updates to type hint).
posborne updated PR #10507.
fitzgen submitted PR review:
Thanks!
fitzgen merged PR #10507.
Last updated: Apr 17 2025 at 23:03 UTC