py-spy
py-spy copied to clipboard
Hours "behind in sampling" when computer sleeps
I had a long profiling job running. It didn't finish in the evening so I left the computer running over night... but Windows decided to automatically suspend after a period of inactivity. When the computer woke back up, py-spy claimed to be some hours behind in sampling, and now seems to try to catch back up by over-sampling the last portion of the job:
py-spy> 3586.69s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3552.40s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3515.31s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3488.67s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3450.05s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3414.78s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3379.09s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3337.14s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3297.54s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3266.70s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3226.69s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3185.79s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3144.04s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3105.82s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3064.52s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 3026.30s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 2984.61s behind in sampling, results may be inaccurate. Try reducing the sampling rate
py-spy> 2931.69s behind in sampling, results may be inaccurate. Try reducing the sampling rate
[...] (until it's back down to 0s)
Is it really over-sampling now to make up for the time spent sleeping?
Ideas:
- Use a different timer (if such a thing exists), or listen to suspend/resume events, so that time spent sleeping doesn't count as "behind in sampling"
- Or maybe just simply give up when behind too much, and drop those outstanding samples instead of trying to re-do them later.
- Use SetThreadExecutionState to prevent the computer from going to sleep while sampling (I guess this is what I wanted in this case)