[Python-Dev] (time) PEP 418 glossary V2
Victor Stinner
victor.stinner at gmail.com
Tue Apr 24 12:38:21 CEST 2012
> Monotonic
> ---------
>
> This is a particularly tricky term, as there are several subtly
> incompatible definitions in use.
Is it a definition for the glossary?
> C++ followed the mathematical
> definition, so that a monotonic clock only promises not to go
> backwards.
The "C++ Timeout Specification" doesn't have any monotonic anymore. It
has a steady_clock, but it's something different.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3128.html#time.clock.monotonic
> In practice, that is not sufficient to be useful, and no
> Operating System provides such a weak guarantee. Most discussions
> of a "Monotonic *Clock*" will also assume several additional
> guarantees, some of which are explicitly required by the POSIX
> specification.
What do you mean for POSIX? The definition of CLOCK_MONOTONIC by the
POSIX specification is:
"The identifier for the system-wide monotonic clock, which is defined
as a clock whose value cannot be set via clock_settime() and which
cannot have backward clock jumps. The maximum possible clock jump
shall be implementation-defined."
http://pubs.opengroup.org/onlinepubs/000095399/basedefs/time.h.html
time.monotonic() of the PEP 418 gives the same guarantee (cannot go
backward, cannot be set), except for "system-wide" (Python cannot give
this guarantee because of Windows older than Vista).
> The tradeoffs
> often include lack of a defined Epoch_ or mapping to `Civil Time`_,
I don't know any monotonic with a defined epoch or mappable to the civil time.
> and being more expensive (in `Latency`_, power usage, or duration spent
> within calls to the clock itself) to use.
CLOCK_MONOTONIC and CLOCK_REALTIME have the same performances on Linux
and FreeBSD. Why would a monotonic clock be more expensive?
> For example, the clock may
> represent (a constant multiplied by) ticks of a specific quartz timer
> on a specific CPU core, and calls would therefore require
> synchronization between cores.
I don't think that synchronizing a counter between CPU cores is
something expensive. See the following tables for details:
http://www.python.org/dev/peps/pep-0418/#performance
CLOCK_MONOTONIC and CLOCK_REALTIME use the same hardware clocksource
and so have the same latency depending on the hardware.
Victor
More information about the Python-Dev
mailing list