py-spy icon indicating copy to clipboard operation
py-spy copied to clipboard

Incomplete profiling results

Open steve36871 opened this issue 2 years ago • 4 comments

Hello! I noticed that ~98% of the samples are missing in my case. I cannot share the profile for reasons of confidentiality, but at the process level, I see ~600.000 samples, and one level below it, only ~11.000 samples are left. This happens with the following parameters: py-spy record -r 1 -s. I intentionally set the sampling rate low because the process runs for about 1 day. How do you think I should interpret this result? What is my application doing 98% of the time when it is inside the process but not within any function inside that process?

steve36871 avatar Apr 21 '23 02:04 steve36871

Do you have a reproducing script that you can share ?

Also what operating system, and python version are you using?

benfred avatar May 09 '23 23:05 benfred

Apologies, I cannot share the script, since I developed it for my employer. I am using CentOS 9 stream within a Docker container and the host is using Debian. The Python version is 3.9.

steve36871 avatar May 10 '23 03:05 steve36871

A possible cause, I think, is an app which runs many "active" threads which have no Python context. For example, fully native threads, or threads that run only Cython code. You can try taking a native profile with perf to see accurately what CPU is spending time on (you'll see if it's native code / Cython / Python interpreter/runtime code, etc).

Jongy avatar May 10 '23 08:05 Jongy

Do you still see missing samples when using py-spy record --native?

EricCousineau-TRI avatar May 26 '23 18:05 EricCousineau-TRI