Time handling overhaul
authorSimon Marlow <marlowsd@gmail.com>
Fri, 25 Nov 2011 13:11:39 +0000 (13:11 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 25 Nov 2011 16:11:36 +0000 (16:11 +0000)
commit6b1098511aaabd2c9503ee7be6da1944466f9cb4
tree83b3001603c7e6a5cfb3ac04adbb99c40504942e
parent18aae18503442276e14a47eabf4786bc7210662e
Time handling overhaul

Terminology cleanup: the type "Ticks" has been renamed "Time", which
is an StgWord64 in units of TIME_RESOLUTION (currently nanoseconds).
The terminology "tick" is now used consistently to mean the interval
between timer signals.

The ticker now always ticks in realtime (actually CLOCK_MONOTONIC if
we have it).  Before it used CPU time in the non-threaded RTS and
realtime in the threaded RTS, but I've discovered that the CPU timer
has terrible resolution (at least on Linux) and isn't much use for
profiling.  So now we always use realtime.  This should also fix

The default tick interval is now 10ms, except when profiling where we
drop it to 1ms.  This gives more accurate profiles without affecting
runtime too much (<1%).

Lots of cleanups - the resolution of Time is now in one place
only (Rts.h) rather than having calculations that depend on the
resolution scattered all over the RTS.  I hope I found them all.
29 files changed:
ghc/ghc.mk
ghc/hschooks.c
includes/Rts.h
includes/rts/Flags.h
includes/rts/storage/TSO.h
rts/GetTime.h
rts/PrimOps.cmm
rts/ProfHeap.c
rts/ProfHeap.h
rts/Profiling.c
rts/Proftimer.c
rts/RtsFlags.c
rts/Schedule.c
rts/Stats.c
rts/Stats.h
rts/Task.c
rts/Task.h
rts/Threads.c
rts/Ticker.h
rts/eventlog/EventLog.c
rts/posix/GetTime.c
rts/posix/Itimer.c
rts/posix/Itimer.h
rts/posix/Select.c
rts/posix/Select.h
rts/sm/GCThread.h
rts/win32/GetTime.c
rts/win32/Ticker.c
rules/build-prog.mk