eos-vm
eos-vm copied to clipboard
Profiler
Running the profiler
The profiler only works with specific template parameters backend<..., jit_profile, ..., profile_instr_map>
. jit_profile
allows capturing stack traces, profile_instr_map
allows mapping host code addresses to offsets in the wasm file.
The profiler can be executed by creating a scoped_profile
object around wasm execution. Multiple profiler instances are supported, but a single thread can only run one at a time.
profile_data pd("file name", bkend); // stores profiling information and writes it to a file
...
{
scoped_profile start(&pd); // start the profiler
bkend.call();
}
The profiler's sampling rate can be set by calling set_profile_interval_us
before starting the profiler. The default is 10 ms.
eos-vm-interp
has an extra -p
option, which enables profiling.
Interpreting the output
The output is generated in the format used by gperftools
. It can be processed by pprof
with the help of a custom addr2line
implementation. eos-vm-addr2line
can only determine the function names. It does not yet know how to parse DWARF, so it cannot provide source line numbers.
Example Usage
eos-vm-interp -p profilee.wasm
pprof --tools=addr2line:path/to/eos-vm/tools/eos-vm-addr2line,objdump:objdump,c++filt:c++filt,nm:nm --collapsed profilee.wasm profile.out > profile.collapsed
flamegraph.pl profile.collapsed > profile.svg