<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 8, 2013 at 7:04 AM, Björn Gustavsson <span dir="ltr"><<a 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 style>It would work reasonably well.</div><div style><br></div><div style>But here's my thinking.</div>
<div style><br></div><div style>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 style><br></div><div style>If wall clock time jumps forward same behavior of both time reading functions is same. We'll tick all missed ticks in that jumped interval. Which is btw a behavior we should consider fixing either. But that's a separate topic.</div>
<div style><br></div><div style>Overall I believe exposing OS monotonic clock is best option for handling clock jumps. Which is a separate topic.</div><div style><br></div><div style>Anyway let me know if you insist on erlang:now</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>How did you find the bug? Do you have a</div><div>test case or a program to provoke the bug?</div>
</div></blockquote><div><br></div><div style>I've spotted timer_server in etop in highest position in our program (management layer of couchbase server) that has few tens of interval timers and started tracing it. Which is how I discovered those weird sequences of timeouts at same timestamp. So no I don't have a test case.</div>
<div style><br></div></div></div></div>