-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better Idle Detection #92
Comments
As part of #92, this adds methods to determine if a thread is idle. This also refactors threads into a struct with common methods across operating systems (id, active, lock etc).
I'm hitting this with 0.2.0.dev1 – py-spy is telling me that my program's spending lots of time in |
As part of #92, this adds methods to determine if a thread is idle. This also refactors threads into a struct with common methods across operating systems (id, active, lock etc).
Let's add |
Rather than use a heuristic to figure out if a thread is active, query the OS to see if the thread is running. This should provide a more accurate view on what's actually happening. The tricky part here is matching the OS thread id to the python thread id, which we were already doing for the native code unwinding. This refactors to allow getting the native thread id even when not getting the native stack. #92
Rather than use a heuristic to figure out if a thread is active, query the OS to see if the thread is running. This should provide a more accurate view on what's actually happening. The tricky part here is matching the OS thread id to the python thread id, which we were already doing for the native code unwinding. This refactors to allow getting the native thread id even when not getting the native stack. #92
Rather than use a heuristic to figure out if a thread is active, query the OS to see if the thread is running. This should provide a more accurate view on what's actually happening. The tricky part here is matching the OS thread id to the python thread id, which we were already doing for the native code unwinding. This refactors to allow getting the native thread id even when not getting the native stack. #92
This PR mostly fixes this issue #123 , by matching up the OS thread to the python thread - and then getting thread activity from the OS. There are a couple of caveats worth pointing out:
|
Can test this out with |
As part of benfred/py-spy#92, this adds methods to determine if a thread is idle. This also refactors threads into a struct with common methods across operating systems (id, active, lock etc).
The current method of marking a thread as idle is based on some heuristics - which don't work in many cases (ie, time.sleep calls can be marked as active, making it hard to view real profile data #87).
With the latest code changes to profile native extensions we have the ability to match the OS thread with the python thread id - meaning that we should be able to figure out from the OS if the thread is idle.
The text was updated successfully, but these errors were encountered: