Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiler #195

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open

Profiler #195

wants to merge 19 commits into from

Conversation

swatanabe-b1
Copy link
Contributor

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

@swatanabe-b1 swatanabe-b1 mentioned this pull request Oct 2, 2020
7 tasks
@swatanabe-b1 swatanabe-b1 mentioned this pull request Oct 2, 2020
7 tasks
include/eosio/vm/debug_info.hpp Show resolved Hide resolved
include/eosio/vm/bitcode_writer.hpp Outdated Show resolved Hide resolved
include/eosio/vm/execution_context.hpp Show resolved Hide resolved
include/eosio/vm/execution_context.hpp Show resolved Hide resolved
include/eosio/vm/profile.hpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants