Skip to content

Conversation

@altendky
Copy link
Member

@altendky altendky commented Aug 6, 2020

Fixes #311

@altendky altendky marked this pull request as draft August 6, 2020 23:19
@altendky
Copy link
Member Author

altendky commented Aug 7, 2020

@nicoddemus, I'd be curious about an explanation of time.perf_counter() being 'more performant' than time.monotonic(). I thought the basic difference was that perf was more related to clock cycles and monotonic was more related to 'wall clock' time. Though I'll admit I haven't dug past that to know what it really means (or perhaps if it is true). I would have guessed that the correct one to use would depend on which most closely matched what Qt uses.

@altendky
Copy link
Member Author

altendky commented Aug 7, 2020

Cool 'you' get this too...

pypi/warehouse#8330

https://github.com/pytest-dev/pytest-qt/pull/312/checks?check_run_id=956248266

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    pyside2 from https://files.pythonhosted.org/packages/03/75/b9f2a292cd092bdbc3032f9b68879a7c270e4cdb81dd09904976d89c0296/PySide2-5.15.0-5.15.0_2-cp35.cp36.cp37.cp38-none-win_amd64.whl#sha256=fad5ce781d0774bfad39f54b6c3376909b8d27f2075cbde6f4499df7dbd855f9:
        Expected sha256 fad5ce781d0774bfad39f54b6c3376909b8d27f2075cbde6f4499df7dbd855f9
             Got        ff1e53be0455c8c5b3bb40c12a35f1608f8860c46a7ebfa70d8a0a67bf8bc125

@nicoddemus
Copy link
Member

I'd be curious about an explanation of time.perf_counter() being 'more performant' than time.monotonic().

'more performant' is not the proper term (my mistake), it is more about being more precise. perf_counter() is often used in benchmarks to measure with more precision the passing of time between two points, monotonic() is meant when you want to measure the passing of time between two points without being affected by system clocks. I didn't really research deep into that, I changed it most as a quick test (which didn't pan out of course).

time.perf_counter is Python 3's solution to the problem in Python 2 of what to use to measure a short duration: on Windows you were supposed to use time.clock(), while on Linux you were supposed to use time.time().

Cool 'you' get this too...

Yeah pretty weird, thanks for taking the topic upstream. 👍

@altendky
Copy link
Member Author

I was curious so...

Linux

monotonic: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09)
perf_counter: namespace(adjustable=False, implementation='clock_gettime(CLOCK_MONOTONIC)', monotonic=True, resolution=1e-09)
process_time: namespace(adjustable=False, implementation='clock_gettime(CLOCK_PROCESS_CPUTIME_ID)', monotonic=True, resolution=1e-09)
thread_time: namespace(adjustable=False, implementation='clock_gettime(CLOCK_THREAD_CPUTIME_ID)', monotonic=True, resolution=1e-09)
time: namespace(adjustable=True, implementation='clock_gettime(CLOCK_REALTIME)', monotonic=False, resolution=1e-09)

macOS

monotonic: namespace(adjustable=False, implementation='mach_absolute_time()', monotonic=True, resolution=1e-09)
perf_counter: namespace(adjustable=False, implementation='mach_absolute_time()', monotonic=True, resolution=1e-09)
process_time: namespace(adjustable=False, implementation='clock_gettime(CLOCK_PROCESS_CPUTIME_ID)', monotonic=True, resolution=1.0000000000000002e-06)
thread_time: namespace(adjustable=False, implementation='clock_gettime(CLOCK_THREAD_CPUTIME_ID)', monotonic=True, resolution=1e-09)
time: namespace(adjustable=True, implementation='clock_gettime(CLOCK_REALTIME)', monotonic=False, resolution=1.0000000000000002e-06)

Windows

monotonic: namespace(adjustable=False, implementation='GetTickCount64()', monotonic=True, resolution=0.015625)
perf_counter: namespace(adjustable=False, implementation='QueryPerformanceCounter()', monotonic=True, resolution=1e-07)
process_time: namespace(adjustable=False, implementation='GetProcessTimes()', monotonic=True, resolution=1e-07)
thread_time: namespace(adjustable=False, implementation='GetThreadTimes()', monotonic=True, resolution=1e-07)
time: namespace(adjustable=True, implementation='GetSystemTimeAsFileTime()', monotonic=False, resolution=0.015625)

So on Windows (only) time.monotonic() and time.perf_counter() do actually use different clocks and the monotonic resolution is reporting the classic 16ms resolution. Awesome... This was Python 3.8 on Azure Pipelines.

@altendky
Copy link
Member Author

So, what's the action here? Another quadrupling of times in hopes of reliably passing for a total of 8x the original times? At some point this isn't measuring response time really and we just kick it to a 30 second timeout.

@nicoddemus
Copy link
Member

nicoddemus commented Aug 12, 2020

Hey @altendky,

Not sure, we might increase those timeouts for mac only perhaps? I'm OK with that if this fixes the issue.

(Wrong button 😅)

I've triggered the build again to see if the mismatch of the hashes for Windows goes away.

@nicoddemus nicoddemus marked this pull request as ready for review August 15, 2020 12:07
@nicoddemus
Copy link
Member

Well I did poke around a little bit but can't figure out why the signals triggered by the timer would take so long. Decided to open #313 and mark those tests as xfail on mac for now: having some testing in place is an improvement already.

Thanks @altendky!

@nicoddemus nicoddemus merged commit 0fb26c0 into pytest-dev:master Aug 15, 2020
@altendky
Copy link
Member Author

QTrio has a bunch of warnings on macOS including comments about being slow. Graphics stuff IIRC but I haven't gotten to digging into them seriously yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should macOS be included in CI?

2 participants