[erlang-patches] [patch] fix excessive CPU consumption of timer_server

Björn Gustavsson bgustavsson@REDACTED
Tue Apr 9 12:00:05 CEST 2013


On Mon, Apr 8, 2013 at 4:55 PM, Aliaksey Kandratsenka <
alkondratenko@REDACTED> wrote:
>
>
> 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).
>
>
That should not happen.

Time correction means that the time returned by erlang:now/0
(and most other time functions) will move one per cent slower
or faster until the correct wall-clock time has been reached. The
time used internally by 'receive after' will also use the corrected time.

We have been thinking about documenting the time
correction mechanism in one place, describing how it works and listing all
time functions and whether they used the corrected time or not.

I should have noted that in git comment but forgot.
>
> Let me know if you need anything more from me. Like adjusted git comment.
>

I suggest that you change your patch to use erlang:now/0 and
verify that it solves the problem in your application.

Alternately, edit your commit message to give us *very* compelling
reasons why os:timestamp/0 would work better than erlang:now/0.

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20130409/f1b01d55/attachment.htm>


More information about the erlang-patches mailing list