pyinstrument icon indicating copy to clipboard operation
pyinstrument copied to clipboard

Provide a warning when time is likely spent in another thread

Open joerick opened this issue 6 years ago • 1 comments

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!

joerick avatar Sep 09 '19 14:09 joerick

Was here looking for something else, but came across this and FWIW a project I did a while ago might help? gilknocker

milesgranger avatar Jun 15 '23 09:06 milesgranger