joerick / joerick/pyinstrument

Provide a warning when time is likely spent in another thread

Open
#71 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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:

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.