summaryrefslogtreecommitdiff
path: root/rts/RtsFlags.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-11-25 13:11:39 +0000
committerSimon Marlow <marlowsd@gmail.com>2011-11-25 16:11:36 +0000
commit6b1098511aaabd2c9503ee7be6da1944466f9cb4 (patch)
tree83b3001603c7e6a5cfb3ac04adbb99c40504942e /rts/RtsFlags.c
parent18aae18503442276e14a47eabf4786bc7210662e (diff)
downloadhaskell-6b1098511aaabd2c9503ee7be6da1944466f9cb4.tar.gz
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.
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r--rts/RtsFlags.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index d8bcf1c915..3e3290dd3d 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -113,7 +113,7 @@ void initRtsFlagsDefaults(void)
#ifdef RTS_GTK_FRONTPANEL
RtsFlags.GcFlags.frontpanel = rtsFalse;
#endif
- RtsFlags.GcFlags.idleGCDelayTime = 300; /* millisecs */
+ RtsFlags.GcFlags.idleGCDelayTime = USToTime(300000); // 300ms
#if osf3_HOST_OS
/* ToDo: Perhaps by adjusting this value we can make linking without
@@ -150,7 +150,7 @@ void initRtsFlagsDefaults(void)
#endif /* PROFILING */
RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
- RtsFlags.ProfFlags.profileInterval = 100;
+ RtsFlags.ProfFlags. heapProfileInterval = USToTime(100000); // 100ms
#ifdef PROFILING
RtsFlags.ProfFlags.includeTSOs = rtsFalse;
@@ -176,8 +176,13 @@ void initRtsFlagsDefaults(void)
RtsFlags.TraceFlags.user = rtsFalse;
#endif
- RtsFlags.MiscFlags.tickInterval = 20; /* In milliseconds */
- RtsFlags.ConcFlags.ctxtSwitchTime = 20; /* In milliseconds */
+#ifdef PROFILING
+ // When profiling we want a lot more ticks
+ RtsFlags.MiscFlags.tickInterval = USToTime(1000); // 1ms
+#else
+ RtsFlags.MiscFlags.tickInterval = DEFAULT_TICK_INTERVAL;
+#endif
+ RtsFlags.ConcFlags.ctxtSwitchTime = USToTime(20000); // 20ms
RtsFlags.MiscFlags.install_signal_handlers = rtsTrue;
RtsFlags.MiscFlags.machineReadable = rtsFalse;
@@ -312,9 +317,9 @@ usage_text[] = {
#if !defined(PROFILING)
"",
-" -hT Heap residency profile (output file <program>.hp)",
+" -h Heap residency profile (output file <program>.hp)",
#endif
-" -i<sec> Time between heap samples (seconds, default: 0.1)",
+" -i<sec> Time between heap profile samples (seconds, default: 0.1)",
"",
#if defined(TICKY_TICKY)
" -r<file> Produce ticky-ticky statistics (with -rstderr for stderr)",
@@ -322,10 +327,15 @@ usage_text[] = {
#endif
" -C<secs> Context-switch interval in seconds.",
" 0 or no argument means switch as often as possible.",
-" Default: 0.02 sec; resolution is set by -V below.",
-" -V<secs> Master tick interval in seconds (0 == disable timer).",
-" This sets the resolution for -C and the profile timer -i.",
" Default: 0.02 sec.",
+" -V<secs> Master tick interval in seconds (0 == disable timer).",
+" This sets the resolution for -C and the heap profile timer -i,",
+" and is the frequence of time profile samples.",
+#ifdef PROFILING
+" Default: 0.001 sec.",
+#else
+" Default: 0.01 sec.",
+#endif
"",
#if defined(DEBUG)
" -Ds DEBUG: scheduler",
@@ -884,11 +894,8 @@ error = rtsTrue;
if (rts_argv[arg][2] == '\0') {
/* use default */
} else {
- I_ cst; /* tmp */
-
- /* Convert to millisecs */
- cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
- RtsFlags.GcFlags.idleGCDelayTime = cst;
+ RtsFlags.GcFlags.idleGCDelayTime =
+ fsecondsToTime(atof(rts_argv[arg]+2));
}
break;
@@ -1090,12 +1097,9 @@ error = rtsTrue;
if (rts_argv[arg][2] == '\0') {
/* use default */
} else {
- I_ cst; /* tmp */
-
- /* Convert to milliseconds */
- cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
- RtsFlags.ProfFlags.profileInterval = cst;
- }
+ RtsFlags.ProfFlags.heapProfileInterval =
+ fsecondsToTime(atof(rts_argv[arg]+2));
+ }
break;
/* =========== CONCURRENT ========================= */
@@ -1104,12 +1108,9 @@ error = rtsTrue;
if (rts_argv[arg][2] == '\0')
RtsFlags.ConcFlags.ctxtSwitchTime = 0;
else {
- I_ cst; /* tmp */
-
- /* Convert to milliseconds */
- cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
- RtsFlags.ConcFlags.ctxtSwitchTime = cst;
- }
+ RtsFlags.ConcFlags.ctxtSwitchTime =
+ fsecondsToTime(atof(rts_argv[arg]+2));
+ }
break;
case 'V': /* master tick interval */
@@ -1118,11 +1119,8 @@ error = rtsTrue;
// turns off ticks completely
RtsFlags.MiscFlags.tickInterval = 0;
} else {
- I_ cst; /* tmp */
-
- /* Convert to milliseconds */
- cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
- RtsFlags.MiscFlags.tickInterval = cst;
+ RtsFlags.MiscFlags.tickInterval =
+ fsecondsToTime(atof(rts_argv[arg]+2));
}
break;
@@ -1358,14 +1356,14 @@ error = rtsTrue;
static void normaliseRtsOpts (void)
{
if (RtsFlags.MiscFlags.tickInterval < 0) {
- RtsFlags.MiscFlags.tickInterval = 50;
+ RtsFlags.MiscFlags.tickInterval = DEFAULT_TICK_INTERVAL;
}
// If the master timer is disabled, turn off the other timers.
if (RtsFlags.MiscFlags.tickInterval == 0) {
RtsFlags.ConcFlags.ctxtSwitchTime = 0;
RtsFlags.GcFlags.idleGCDelayTime = 0;
- RtsFlags.ProfFlags.profileInterval = 0;
+ RtsFlags.ProfFlags.heapProfileInterval = 0;
}
// Determine what tick interval we should use for the RTS timer
@@ -1383,9 +1381,9 @@ static void normaliseRtsOpts (void)
RtsFlags.MiscFlags.tickInterval);
}
- if (RtsFlags.ProfFlags.profileInterval > 0) {
+ if (RtsFlags.ProfFlags.heapProfileInterval > 0) {
RtsFlags.MiscFlags.tickInterval =
- stg_min(RtsFlags.ProfFlags.profileInterval,
+ stg_min(RtsFlags.ProfFlags.heapProfileInterval,
RtsFlags.MiscFlags.tickInterval);
}
@@ -1397,12 +1395,12 @@ static void normaliseRtsOpts (void)
RtsFlags.ConcFlags.ctxtSwitchTicks = 0;
}
- if (RtsFlags.ProfFlags.profileInterval > 0) {
- RtsFlags.ProfFlags.profileIntervalTicks =
- RtsFlags.ProfFlags.profileInterval /
+ if (RtsFlags.ProfFlags.heapProfileInterval > 0) {
+ RtsFlags.ProfFlags.heapProfileIntervalTicks =
+ RtsFlags.ProfFlags.heapProfileInterval /
RtsFlags.MiscFlags.tickInterval;
} else {
- RtsFlags.ProfFlags.profileIntervalTicks = 0;
+ RtsFlags.ProfFlags.heapProfileIntervalTicks = 0;
}
if (RtsFlags.GcFlags.stkChunkBufferSize >