cli
cli copied to clipboard
[FEATURE REQUEST] Support more profilers with `fastly compute serve`
Is your feature request related to a problem? Please describe.
The fastly compute serve --profile-guest
option works on all platforms and doesn't require installing any additional software, so it's a great default choice for profiling, but it has some limitations compared to native profilers like Linux perf
or Intel VTune. Viceroy supports these other profilers via its --profile
option but the Fastly CLI doesn't expose those alternatives when invoking Viceroy with fastly compute serve
.
Describe the solution you'd like
Add an option to fastly compute serve
that causes it to pass e.g. --profile=jitdump
to Viceroy. Currently Viceroy also supports perfmap
and vtune
variants.
It would be preferable to also wrap Viceroy in the appropriate profiler. For example, profiling with VTune means running vtune -run-pass-thru=--no-altstack -collect hotspots viceroy --profile=vtune
instead of just running viceroy
.
When using Linux perf
in jitdump
mode, after recording the profile with perf record
, the user has to additionally run something like perf inject --jit --input perf.data --output perf.jit.data
. It would be nice to do this for them. It would also be nice to have perf record
write to a temporary file and have perf inject
output to the perf.data
name that perf report
expects to read from.
The user may want to pass additional options to the profiler so it would be good to have an option for that.
Describe alternatives you've considered Adding support for passing through uninterpreted arguments to Viceroy, as suggested in #1047, might work here too. However, that means the user has to wrap the profiler around the Fastly CLI and ensure that it profiles child processes as well, which not only makes the user experience more complex but will add a bunch of data they don't care about to the profile.
In the future, Wasmtime and Viceroy may gain support for more profilers. It would be nice if we didn't need to change the Fastly CLI to support new profilers, which would suggest making the profiler name be an uninterpreted string. We could probably define some way for Viceroy to tell the CLI what profilers it supports and perhaps how to invoke them, or make Viceroy re-spawn itself under the appropriate profiler.
Additional context
The Wasmtime book documents Wasmtime's support for external profilers, specifically perf and VTune. There's also documentation on using Samply with Wasmtime which relies on the same perfmap
profiling mode that perf
can use.