On Apr 5, 2012, at 8:07 PM, Zooko Wilcox-O'Hearn wrote:

> On Thu, Apr 5, 2012 at 7:14 PM, Greg Ewing <greg.ew...@canterbury.ac.nz> 
> wrote:
>> 
>> This is the strict mathematical meaning of the word "monotonic", but the way 
>> it's used in relation to OS clocks, it seems to mean rather more than that.
> 
> Yep. As far as I can tell, nobody has a use for an unsteady, monotonic clock.
> 
> There seem to be two groups of people:
> 
> 1. Those who think that "monotonic clock" means a clock that never
> goes backwards. These people are in the majority. After all, that's
> what the word "monotonic" means ¹ . However, a clock which guarantees
> *only* this is useless.

While this is a popular view on this list and in this discussion, it is also a 
view that seems to contradict quite a lot that has been written on the subject, 
and seems contrary to the usual jargon when referring to clocks.

> 2. Those who think that "monotonic clock" means a clock that never
> jumps, and that runs at a rate approximating the rate of real time.
> This is a very useful kind of clock to have! It is what C++ now calls
> a "steady clock". It is what all the major operating systems provide.

All clocks run at a rate approximating the rate of real time.  That is very 
close to the definition of the word "clock" in this context.  All clocks have 
flaws in that approximation, and really those flaws are the whole point of 
access to distinct clock APIs.  Different applications can cope with different 
flaws.

There seems to be a persistent desire in this discussion to specify and define 
these flaws out of existence, where this API really should instead be embracing 
the flaws and classifying them.  (Victor is doing a truly amazing job with the 
PEP in that regard; it's already the first web search hit on every search 
engine I've tried for more than half of these terms.)

Steadiness, in the C++ sense, only applies to most OS clocks that are given the 
label of "monotonic" during the run of a single program on a single computer 
while that computer is running at some close approximation of full power.

As soon as you close your laptop lid, the property of steadiness with respect 
to real local time goes away; the clock stops ticking forward, and only resumes 
when the lid is opened again.  The thing I'd like to draw attention to here is 
that when you get one of these clocks, you *do not* get a parallel facility 
that allows you to identify whether a suspend has happened (or, for that 
matter, when the wall clock has stepped).  Or at least, nobody's proposed one 
for Python.  I proposed one for Twisted, 
<http://twistedmatrix.com/trac/ticket/2424#comment:26>, but you need an event 
loop for that, because you need to be able to register interest in that event.

I believe that the fact that these clocks are only semi-steady, or only steady 
with respect to certain kinds of time, is why the term "monotonic clock" 
remains so popular, despite the fact that mathematical monotonicity is not 
actually their most useful property.  While these OS-provided clocks have other 
useful properties, they only have those properties under specific conditions 
which you cannot necessarily detect and you definitely cannot enforce.  But 
they all remain monotonic in the mathematical sense (modulo hardware and OS 
bugs), so it is the term "monotonic" which comes to label all their other, more 
useful, but less reliable properties.

> The people in class 1 are more correct, technically, and far more
> numerous, but the concept from 1 is a useless concept that should be
> forgotten.

Technically correct; the best kind of correct!

The people in class 1 are only more correct if you accept that mis-applying 
jargon from one field (mathematics) to replace generally-accepted terminology 
in another field (software clocks) is the right thing to do.  I think it's 
better to learn the local jargon and try to apply it consistently.  If you 
search around the web for the phrase "monotonic clock", it's applied in a sense 
closest to the one you mean on thousands and thousands of web pages.  "steady 
clock" generally applies with reference to C++, and even then is often found in 
phrases like "is_steady indicates whether this clock is a monotonic clock".

Software developers "mis"-apply mathematical terms like "isomorphic", 
"orthogonal", "incidental", "tangential", and "reflexive" all the time.  
Physicists and mathematicians also disagree on the subtleties of the same 
terms.  Context is everything.

> So before proceeding, we should mutually agree that we have no
> interest in implementing a clock of type 1. It wouldn't serve anyone's
> use case (correct me if I'm wrong!) and the major operating systems
> don't offer such a thing anyway.

+1.

> Then, if we all agree to stop thinking about that first concept, then
> we need to agree whether we're all going to use the word "monotonic
> clock" to refer to the second concept, or if we're going to use a
> different word (such as "steady clock") to refer to the second
> concept. I would prefer the latter, as it will relieve us of the need
> to repeatedly explain to newcomers: "That word doesn't mean what you
> think it means.".

I don't think anything can (or should) relieve that need.

I am somewhat sympathetic to your preference for "steady" as a better overall 
term.  It does express the actually-desired property of the clock, even if that 
property isn't always present; steadiness is not a property that one can be 
tempted to synthesize, so it removes the temptation to cloud the discussion 
with that.  Ultimately I don't prefer it, because I think its provenance is 
less venerable than "monotonic", just because I have a bit more respect for the 
POSIX committee than the C++ one :-).

However, whatever choice we make in terminology, the documentation for this API 
must stress what it actually does, and what guarantee it actually provides.  In 
that sense, my preferred term for this would be the 
"time.zfnrg_lfj_lpqq(ZFNRG_TIME | ZFNRG_SEMI_STEADY | ZFNRG_SEE_DOCUMENTATION)".

> The main reason to use the word "monotonic clock" to refer to the
> second concept is that POSIX does so, but since Mac OS X, Solaris,
> Windows, and C++ have all avoided following POSIX's mistake, I think
> Python should too.

Do you just mean that the APIs don't have "monotonic" in the name?  They all 
use different words, which strikes me as more of a failure than a success, in 
the realm of making mistakes about communicating things :).

> Regards,
> 
> Zooko
> 
> ¹ http://mathworld.wolfram.com/MonotonicSequence.html
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/glyph%40twistedmatrix.com

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to