Granulate / gprofiler

gProfiler is a system-wide profiler, combining multiple sampling profilers to produce unified visualization of what your CPU is spending time on.
https://profiler.granulate.io
Apache License 2.0
746 stars 54 forks source link

python: native functions calling to python functions are not displayed #734

Open Jongy opened 1 year ago

Jongy commented 1 year ago

Native functions can be functions of the Python runtime, or Cythonized functions.

py-spy does not collect native frames at all right now (it supports collection but we don't enable this mode, partially because I'm under impression it's very inaccurate under --nonblocking mode). PyPerf does collect native frames, but we stop at the first Python function (i.e the first PyEval_EvalFrame*).

If we have a stack like: python; pyfunc1; pyfunc2; cythonfunc3; cythonfunc4; pyfunc5 ... then both py-spy and PyPerf will collect it as python; pyfunc1; pyfunc2; pyfunc5 ....

I don't have a good idea for it now, perhaps PyPerf can collect deeper native frames and correlate frames also with frames higher in the stack than the first Python frames?