[erlang-questions] erlang time in vmware

Per Hedeland <>
Sat Nov 17 11:24:40 CET 2007


Richard Andrews <> wrote:
>
>[ Fredrik Thulin wrote: ]
>> My Erlang VM however, ended up ~270 seconds into the future after 
>> running for about a week. The system time as reported by 'date' showed 
>> correct time. Can someone explain this, and hopefully also tell me how 
>> to avoid it in the future?
>
>From my observations of erlang under Linux via strace I see that it makes
>extensive use of clock_gettime( CLOCK_MONOTONIC ). CLOCK_MONOTONIC combined
>with vmware modifying kernel clock ticks might lead to this effect. If vmware
>inserts additional timing ticks to try and acount for time periods in which the
>guest kernel is not running, then erlang might see the time as in the future if
>it measures wall time as (StartTime + Ticks).

It doesn't, but it does "compensate" for sudden changes in wall clock
time (i.e. due to the clock having been stepped) by using ticks on OSes
where this is possible (e.g. Linux). See the +c flag in the erl(1) man
page (and/or erts/emulator/beam/erl_time_sup.c if you're *really*
curious:-). This might still have the described result if vmware does
what you think it does - i.e. the ticks marching on while wall clock
time doesn't would be interpreted as wall clock time being stepped back.

However I can't really see how vmware could literally "insert ticks" in
an unmodified guest kernel - what it can and must do is of course to
generate timer interrupts, but those should be turned into both ticks
and wall clock advancement by the guest kernel, i.e. they should keep in
sync. Maybe if it keeps generating too many interrupts, and keeps
"compensating" by setting wall clock time back - I guess the vmware
tools stuff that Fredrik mentions will do the latter if it needs to.

It may possibly help to tell the guest Linux to use a lower "Hz" (kernel
compile-time thing unfortunately if I remember right). Or try to use NTP
againast vmware's recommendations, it has worked fine for me - I've
never run Linux 2.6 in vmware though, but for 2.4 in (old) vmware or 2.6
in qemu NTP has been OK for keeping system time. It would surely require
disabling the part of vmware tools that "keeps time" though, don't know
if that is possible.

--Per Hedeland



More information about the erlang-questions mailing list