-
Notifications
You must be signed in to change notification settings - Fork 240
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
Support multithreaded profiling #352
Comments
This would definitely be a great feature to have in pyinstrument. As a workaround until/if this feature gets picked up, I've come up with the following hack to automatically profile newly spawned threads by (ab)using One can detect when a thread has started, and start the profiler when I had to use |
Take a look at the referenced PR - it does much of that but also allows viewing the timelines of all threads together. |
@georgeharker I've already had a look, I need to dedicate some time on integrating it with my project. My biggest issue with the PR in its current state is that the majority of tests are failing, there are some missing updates to the Session class in various methods, and the linters seem to be complaining. Changing the return type for the Profiler from a list of frames to a dictionary seems like a tough breaking change. Maybe this multi threading aware code can be placed into its own class, leaving us with two kinds of profilers? |
Yeah there's still work to do there for sure! Just did enough for my needs and wanted some feedback about what it would look like to get it into a state for merge |
Thanks for pyintrument - it's incredibly useful
I had need to trace a multithreaded python app and examine the relationship between threads. Obviously in some cases multithreading can be a little interesting in python, but in this particular case works well.
I have extended a fork of pyinstrument to support showing all child threads from the one where profiling starts. I get nice results with all threads separated which has been hugely helpful.
I'll file a PR and reference this issue. It's still a bit of a WIP, but i'd be curious to see if it looks reasonable to you.
The text was updated successfully, but these errors were encountered: