Open jendap opened 4 months ago
As an alternative to using perf
you could try using my branch of https://github.com/jrmuizel/py-spy/tree/gecko-profiler and then loading the resulting json using samply load
.
Here's an example: https://share.firefox.dev/4c5iJDy
We forgot to answer the initial question: yes we're interested! It should be possible to detect a python-origin linux-perf profile and do some pre-filtering or even completely move the parsing to a different function.
We also have a bunch of random scripts in bin/, maybe we could put your cleaning script there already, along with some documentation to docs-user/
. The new documentation could also mention @jrmuizel's option.
@jrmuizel nice! Although it may need some more work. Your branch said "rote ... Samples: 1452", the file had 20kB. But the profile? https://share.firefox.dev/49KblMm
Py-spy may be cute but perf is the unrivaled (on linux).
I will look into bin directory. I may send a PR (in a few weeks).
BTW: Are there any plans to make the profiler UI more generic (less Firefox specific)?
Python 3.12 has support for linux perf. Firefox profiler is the best ui. Using them together with the recommended
perf script -F +pid > test.perf
works but it could be better. Python is wildly used. Would you be interested in improvements for it in profiler codebase?The generated stack trace (by perf script) looks like:
The improvements from here can be:
_PyEval_EvalFrameDefault.cold
andPyObject_Vectorcall
. Similar (and even bigger) noise is around generators and async. All cPython interpreter frames.py::Process.username:/tmp/test/top/psutil/__init__.py+0x6 (/tmp/perf-1810767.map)
as function namepy::Process.username:/tmp/test/top/psutil/__init__.py
at file/tmp/perf-1810767.map
. Obviously that could be better.cfunction_vectorcall
on stack trace before anypy::*
may indicate that. But it may not be trivial.I have quickly tried
perf script -F +pid | ./python_perf_cleaner.py > test.perf
. Where mypython_perf_cleaner.py
is:This is a big improvement for me. It does solve the first two issues!
For the third issue - identifying native frames... Looking at linux-perf.js I don't see an easy way to rewrite the stack traces even if one would figure out how to recognize them.
The question is if anybody (but me) cares about this? How to do it if so? Hacking directly the perf import in this codebase? Or maybe throwing the improved python reprocessing script to github. But the script would have to start writing your Profile.
BTW: Similar (but much easier) is Java. It is also big ecosystem. Might be worth extra few lines to make it nicer. BTW: Is there (both ways) convertor of your Profile to Google's pprof (profile.proto)[https://github.com/google/pprof/blob/main/proto/profile.proto]?
┆Issue is synchronized with this Jira Task