Add PyPerf, example of profiling Python using BPF #2239
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a tool attaches BPF program to CPU Perf Events for profiling. The BPF program understands CPython internal data structure and hence able to walk actual Python stack-trace, as oppose to strac-trace of the CPython runtime itself as we would normally get with Linux
perf
.To use the tool, just run the
PyPerf
binary:-d
/--duration
to specify intended profiling duration, in milliseconds. Default value, if not specified, is1000ms
.-c
/--sample-rate
to specify intended profiling sample rate, same as-c
argument of Linuxperf
. Default value, if not specified, is1e6
.You can also use
-v
/--verbose
to specify logging verbosity1
or2
for more detailed information during profiling.The tool is a prototype at this point is by no mean mature. It currently has follow limitation:
python-devel
and get them directly from the header files.Landing it in C++ example for now, once it's mature enough I will move it to
tools/
.Feel free to try it out and let me know what do you think!