[Python-Dev] Use QueryPerformanceCounter() for time.monotonic() and/or time.highres()?

Victor Stinner victor.stinner at gmail.com
Sun Apr 1 03:56:27 CEST 2012


> FYI, Victor, the PEP is slightly incomplete.

Sure. What should be added to the PEP?

> But there's another problem: the TSC frequency actually *does*
> change when SpeedStep kicks in.  I know someone who complained bitterly
> about running Half-Life 2 on their shiny new laptop, and when it'd overheat
> SpeedStep would knock down the processor speed and the game's logic update
> rate would drop in half and now Gordon was running through molasses.

Yes, I already changed the PEP to not use QPC anymore for
time.monotonic() because it has too many issues.

I didn't mention the CPU frequency change issue in the PEP because I
failed to find recent information about this issue. Is it an old bug
or does it still occur with Windows Vista or Seven? Does Windows Vista
and Seven still use TSC or they prefer other hardware clocks like ACPI
PMT or HPET?

Last info that I found: "Historically, the TSC increased with every
internal processor clock cycle, but now the rate is usually constant
(even if the processor changes frequency) and usually equals the
maximum processor frequency. The instructor RDTSC can be used to read
this counter."

> The documentation warnings about timeBeginPeriod is ancient, like Windows 95 era.

Which warning? The power consumption issue mentioned in the PEP?

> Likewise with calling into winmm--it shipped with every OS 3.3
> supports.  It's just not a big deal and you don't need to mention it in the
> PEP.

I mentioned that the function requires the winmm library because a
static or dynamic link to a library can be an issue. Especially if we
use this function in Python core. clock_gettime(CLOCK_REALTIME) is not
used on Linux for _PyTime_gettimeofday() because it requires to link
Python to the rt (real-time) library, but it is used by time.time() (I
changed it recently).

Victor


More information about the Python-Dev mailing list