[WIP] bpo-36205: incorrect time.process_time when built on macOS < 10.12#12287
[WIP] bpo-36205: incorrect time.process_time when built on macOS < 10.12#12287ned-deily wants to merge 1 commit intopython:masterfrom
Conversation
|
I am not excited by tests on clocks. In the past, I had to remove such tests which were too fragile. Would it make sense to add a test on time.get_clock_info()? Maybe a test specific to macOS? |
|
@vstinner I am usually not excited by clock tests either. However, I was looking for you to investigate why process_time has been broken in 3.7 :) Also, I would think that this problem might be seen on other platform/versions that lack |
|
Good call, @vstinner! It looks like the test case as it stands is too fragile: it failed on the Azure Pipeline win64. Well, it should still be useful in figuring out what the problem is. We can decide later whether to make it more robust and add to the repo. |
|
Yeah, please don't add such test which rely too much on clock resolution/accuracy. These tests fail often in the past, it's very painful to fix them. For example, I modified some tests to tolerate a delta of 1 second on a duration which should be 20 ms... Such test doesn't make an sense anymore... |
|
I still think it would be better to have a test for this case since the problem embarrassingly went undetected for quite some time. But I'll let some one else deal with it if they care to. |
bpo-36205 documents a problem where
time.process_timeandtime.perf_counterreturn very different values when built on macOS 10.11 or earlier. Several time related functions were added to macOS at 10.12 includingclock_gettime. For older systems, timemodule.c falls back to usinggetrusage. With Python 3.6.x, that fallbacks correctly but it appears that refactoring introduced with the implementation of PEP 564 (bpo-31784, #3989) broke that for 3.7.z.This initial PR just includes a potential test case to ensure process_time and perf_counter return similar results. It can be used to reproduce the problem when building on newer versions of macOS (10.12+) by removing the
AC_CHECK_FUNCS(clock_gettime)test inconfigure.ac:and running the test in this PR:
https://bugs.python.org/issue36205