<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 04/08/2013 04:55 PM, Aliaksey
Kandratsenka wrote:<br>
</div>
<blockquote
cite="mid:CADpJO7z-6D6BEwniuo8xNXW+nMmGMoLF8jQ2xXuKbuDBwuVnfw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Mon, Apr 8, 2013 at 7:40 AM,
Aliaksey Kandratsenka <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:alkondratenko@gmail.com" target="_blank">alkondratenko@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
<div class="im">On Mon, Apr 8, 2013 at 7:04 AM,
Björn Gustavsson <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:bgustavsson@gmail.com"
target="_blank">bgustavsson@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0
0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="ltr">Thanks for the bug report and
patch!
<div><br>
</div>
<div>The patch, however, is not acceptable
since</div>
<div>it replaces a call to erlang:now/0 with a
call to</div>
<div>os:timestamp/0. os:timestamp/0 does no</div>
<div>time correction while erlang:now/0 does,
so there</div>
<div>will be trouble if time correction is
being done.</div>
<div><br>
</div>
<div>Did you have any particular reason to use</div>
<div>
os:timestamp/0? It seems to me that using</div>
<div>erlang:now/0 should work just as well.</div>
</div>
</blockquote>
<div><br>
</div>
</div>
<div>It would work reasonably well.</div>
<div><br>
</div>
<div>But here's my thinking.</div>
<div><br>
</div>
<div>If wall clock time jumps backward then
os:timestamp will also jump backwards and we're
screwed. I.e. no ticks will happen until time will
naturally advance to a time before jump.
erlang:now will not jump backwards, but it will
not do any "time correction" either. It'll just
"crawl forward" by 1 microsecond per erlang:now
call which is in my definition screwed either.</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div style="">Actually I forgot but my thinking was a bit
more elaborate.</div>
<div style=""><br>
</div>
<div style="">If we use erlang:now and time jumps backwards.
We'll have time as seen by receive X -> X after
AfterMillis -> ok end flow normally, but erlang:now
will crawl. Which can be seen to cause same busy wait in
timer server but just for much longer (i.e. until
erlang:now overtakes os:timestamp where that "never go
back" code path stops being hit and time flows normal
again).</div>
</div>
</div>
</div>
</blockquote>
Erlang:now() will not crawl. It will move forward at a steady pace
which is the best approximation of time moving forward, exactly as
the timers. It will very slowly *converge* with the wall clock time.
Time, as now() presents it, might move one percent slower or faster
than what your wall-clock shows, but it will never "crawl".<br>
<br>
now() is the best approximation of the time in the system. If the
wall clock moves it will try to converge, as the assumption is the
wall clock has moved for a reason. now() uses a monotonic timer
together with the wall clock to estimate a "real" time, which is the
best we can get given normal hardware. <br>
<br>
Unfortunately someone also thought that now() should give unique
values, which makes it a bottleneck and has prompted more use of
os:timestamp() than what's really good. timestamp() will jump around
like crazy if someone decides to "fix the time" on the box, giving
all kinds of troubles. It can be used for logging, debugging,
profiling etc, but never for real timeouts.<br>
<br>
Best regards,<br>
/Patrik<br>
<blockquote
cite="mid:CADpJO7z-6D6BEwniuo8xNXW+nMmGMoLF8jQ2xXuKbuDBwuVnfw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div style=""><br>
</div>
<div style="">I should have noted that in git comment but
forgot.</div>
<div style=""><br>
</div>
<div style="">Let me know if you need anything more from me.
Like adjusted git comment.</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-patches mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-patches@erlang.org">erlang-patches@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-patches">http://erlang.org/mailman/listinfo/erlang-patches</a>
</pre>
</blockquote>
<br>
</body>
</html>