stdlib Timer bug

Michael McDaniel erlang@REDACTED
Wed Oct 5 18:37:24 CEST 2005


Entering the following into google turns up some interesting 
discussions about clock changes.

"clock changes" site:www.erlang.org


I seem to remember an environment variable or flag that can
be set to change timer behaviour from gradual synchronization
to instant synchronization with system clock.
However, I cannot find any reference, and may be remembering
incorrectly.


~Michael



On Wed, Oct 05, 2005 at 01:46:04PM +0200, Rudolph van Graan wrote:
> Hi there,
> 
>   {ok,TRef} = timer:apply_interval(2000,null,go,[]);
> 
> go() ->
>   TS = calendar:now_to_local_time(now()),
>   io:format("Tick ~p\n",[TS]).
> 
> This works as expected:
> 
> Tick {{2005,10,5},{13,39,8}}
> Tick {{2005,10,5},{13,39,10}}
> Tick {{2005,10,5},{13,39,12}}
> Tick {{2005,10,5},{13,39,14}}
> Tick {{2005,10,5},{13,39,16}}
> Tick {{2005,10,5},{13,39,18}}
> Tick {{2005,10,5},{13,39,20}}
> 
> Now I put the machine to sleep
> and wait 20s
> 
> Now the timer tries to catch up with the system and posts events for  
> the time the machine was sleeping:
> 
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> Tick {{2005,10,5},{13,39,39}}
> 
> And now it continues as per usual
> 
> Tick {{2005,10,5},{13,39,40}}
> Tick {{2005,10,5},{13,39,42}}
> Tick {{2005,10,5},{13,39,44}}
> Tick {{2005,10,5},{13,39,46}}
> Tick {{2005,10,5},{13,39,48}}
> Tick {{2005,10,5},{13,39,50}}
> 
> My issue is that if a machine sleeps for 5 hours or more, we can get  
> millions of these events in the queue. Obviously, it is not an issue  
> on "always on" type systems and is only  visible on my laptop.  
> However, I still think there should be a patch for timer to skip  
> ahead if it is too far behind and not to try and make things worse.  
> On my test system, this effect basically destroys my VM as each timer  
> message launches a new process which essentially kills the OS.
> 
> Suggestions?
> 
> Rudolph van Graan
> 



More information about the erlang-questions mailing list