Skip to content
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

Option to get native thread ID with best effort #625

Open
ErnestChan opened this issue Oct 24, 2023 · 2 comments
Open

Option to get native thread ID with best effort #625

ErnestChan opened this issue Oct 24, 2023 · 2 comments

Comments

@ErnestChan
Copy link

When running py-spy with --native sometimes I get failed to get os threadid. See related issue. I'm running this on bare-metal Ubuntu servers.

It would be great to have the option to not error out when py-spy fails to get the thread id. Maybe modify this line so when the option is set we log an exception, or add a fake stack trace that says py-spy failed to get the thread ID

@benfred
Copy link
Owner

benfred commented Oct 25, 2023

With the --native option, we need to be able to get a mapping between pthread_id and the OS thread_id - so that we can join the native stack (which we have the OS thread_id for) with the python stack (which we have the pthread_id for). If we fail to get the os threadid, there isn't enough information to do this -

What version of python and ubuntu are you running? This code should work to get the os threadid on ubuntu (aside from in cases like profiling from the host os into a docker container - which doesn't sound like it applies to you).

@ErnestChan
Copy link
Author

Thanks for the quick reply! This is on Ubuntu 22.04.1 LTS profiling python3.8. If the code should work on Ubuntu do you have pointers on how to debug why it sometimes fails?

As for joining pthread_id and OS thread_id, for us we're ok with missing some native thread stack traces. We'd rather get some native traces than none, which is why a best effort option with --native would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants