benfred / py-spy

Sampling profiler for Python programs
MIT License
12.16k stars 401 forks source link

Add a flag to only scan python.exe processes #561

Open jan11011977 opened 1 year ago

jan11011977 commented 1 year ago

We are running py-spy on a process tree which contains both python.exe interpreters and 'normal' windows programs. We use the '--subprocess' flag to profile all these processes, which is very cool. However we are running into a problem where py-spy is using a lot of CPU because every time a non-python process is started, it tries to look for the python symbols. This searching for symbols is very slow (it can take dozens of seconds). If we spawn a lot of these non-python subprocesses, py-spy ends up gobbling up all CPU.

What would be amazing, is some way to only try to scan python.exe processes, and ignore other processes. Maybe there could be a commandline flag that says "only instrument this process"?

Thank you for an amazing tool!