Open encukou opened 9 months ago
AssertionError: 0.015625 not less than or equal to 0.0078125
The problem here is that time.monotonic() has a resolution of 15.6 ms on Windows. It can return 0 or 15.6 ms for short timing, nothing in between. I added "CLOCK_RES" to some tests:
$ grep 'CLOCK_RES =' Lib/test/ -R
Lib/test/test_asyncio/utils.py:CLOCK_RES = 0.050
Lib/test/_test_eintr.py:CLOCK_RES = 0.020
Lib/test/_test_multiprocessing.py:CLOCK_RES = 0.100
Lib/test/test_os.py: CLOCK_RES = CLOCK_RES_NS * 1e-9
The problem here is that time.monotonic() has a resolution of 15.6 ms on Windows
I don't know if it's the root issue or not. I will try to reproduce to debug the issue on Windows.
Hm, this is usingprocess_time
. Should it use perf_counter
instead?
@terryjreedy, do you see this on a machine where you could test a fix?
I observed 2 failures in about 18 tries on installed 3.13.0 no-debug gil. I could hand-patch (copy-patch) a bit of test_int.
On fairly fresh local debug no-gil build I got 0 failures in 40 tries. Easy to patch from PR, but need something that fails to test fix.
The problem here is that time.monotonic() has a resolution of 15.6 ms on Windows.
I changed time.monotonic() in Python 3.13 to use QueryPerformanceCounter(). It now has a resolution better than 1 microsecond.
test_int
recently failed on a buildbot:I don't know for sure, but my guess is that a GC collection got triggered at the wrong time.
I'd like to add a test helper for timing CPU-bound tasks. It should disable GC and use
process_time
; perhaps it can do other tricks in the future too.Linked PRs