joerick / joerick/pyinstrument
Provide a warning when time is likely spent in another thread
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 301
- PR merge metrics
- No merged PRs in 30d
Description
pyinstrument only records one thread at a time. However, due to the GIL, the performance of one thread could be affected by a different active thread in the same program.
Python can now give CPU time per-thread:
- https://docs.python.org/3/library/time.html#time.thread_time
- https://docs.python.org/3/library/time.html#time.clock_gettime
This could be compared with the program CPU time - if the current thread is less than 80% of the program's CPU time, it's likely that that other thread was slowing the profiled one down - this should be communicated in pyinstrument's output.
It would be even better if we could track the time spent inside the GIL (and even subtract it), but I'm not sure how to do that!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Python's time.thread_time and time.clock_gettime documentation and tracing where pyinstrument formats profiler output. Compare current-thread CPU time with program CPU time, then verify that output communicates when the current thread accounts for less than 80% of CPU time and may be affected by another thread.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100