Detect overly long GC sync
[ghc.git] / includes / rts / Flags.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2009
4 *
5 * Datatypes that holds the command-line flag settings.
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #pragma once
15
16 #include <stdio.h>
17 #include <stdint.h>
18 #include <stdbool.h>
19 #include "stg/Types.h"
20 #include "Time.h"
21
22 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
23
24 /* Note [Synchronization of flags and base APIs]
25 *
26 * We provide accessors to RTS flags in base. (GHC.RTS module)
27 * The API should be updated whenever RTS flags are modified.
28 */
29
30 /* See Note [Synchronization of flags and base APIs] */
31 typedef struct _GC_FLAGS {
32 FILE *statsFile;
33 uint32_t giveStats;
34 #define NO_GC_STATS 0
35 #define COLLECT_GC_STATS 1
36 #define ONELINE_GC_STATS 2
37 #define SUMMARY_GC_STATS 3
38 #define VERBOSE_GC_STATS 4
39
40 uint32_t maxStkSize; /* in *words* */
41 uint32_t initialStkSize; /* in *words* */
42 uint32_t stkChunkSize; /* in *words* */
43 uint32_t stkChunkBufferSize; /* in *words* */
44
45 uint32_t maxHeapSize; /* in *blocks* */
46 uint32_t minAllocAreaSize; /* in *blocks* */
47 uint32_t largeAllocLim; /* in *blocks* */
48 uint32_t nurseryChunkSize; /* in *blocks* */
49 uint32_t minOldGenSize; /* in *blocks* */
50 uint32_t heapSizeSuggestion; /* in *blocks* */
51 bool heapSizeSuggestionAuto;
52 double oldGenFactor;
53 double pcFreeHeap;
54
55 uint32_t generations;
56 bool squeezeUpdFrames;
57
58 bool compact; /* True <=> "compact all the time" */
59 double compactThreshold;
60
61 bool sweep; /* use "mostly mark-sweep" instead of copying
62 * for the oldest generation */
63 bool ringBell;
64
65 Time idleGCDelayTime; /* units: TIME_RESOLUTION */
66 bool doIdleGC;
67
68 Time longGCSync; /* units: TIME_RESOLUTION */
69
70 StgWord heapBase; /* address to ask the OS for memory */
71
72 StgWord allocLimitGrace; /* units: *blocks*
73 * After an AllocationLimitExceeded
74 * exception has been raised, how much
75 * extra space is given to the thread
76 * to handle the exception before we
77 * raise it again.
78 */
79 StgWord heapLimitGrace; /* units: *blocks*
80 * After a HeapOverflow exception has
81 * been raised, how much extra space is
82 * given to the thread to handle the
83 * exception before we raise it again.
84 */
85
86 bool numa; /* Use NUMA */
87 StgWord numaMask;
88 } GC_FLAGS;
89
90 /* See Note [Synchronization of flags and base APIs] */
91 typedef struct _DEBUG_FLAGS {
92 /* flags to control debugging output & extra checking in various subsystems */
93 bool scheduler; /* 's' */
94 bool interpreter; /* 'i' */
95 bool weak; /* 'w' */
96 bool gccafs; /* 'G' */
97 bool gc; /* 'g' */
98 bool block_alloc; /* 'b' */
99 bool sanity; /* 'S' warning: might be expensive! */
100 bool stable; /* 't' */
101 bool prof; /* 'p' */
102 bool linker; /* 'l' the object linker */
103 bool apply; /* 'a' */
104 bool stm; /* 'm' */
105 bool squeeze; /* 'z' stack squeezing & lazy blackholing */
106 bool hpc; /* 'c' coverage */
107 bool sparks; /* 'r' */
108 bool numa; /* '--debug-numa' */
109 bool compact; /* 'C' */
110 } DEBUG_FLAGS;
111
112 /* See Note [Synchronization of flags and base APIs] */
113 typedef struct _COST_CENTRE_FLAGS {
114 uint32_t doCostCentres;
115 # define COST_CENTRES_NONE 0
116 # define COST_CENTRES_SUMMARY 1
117 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
118 # define COST_CENTRES_ALL 3
119 # define COST_CENTRES_JSON 4
120
121 int profilerTicks; /* derived */
122 int msecsPerTick; /* derived */
123 char const *outputFileNameStem;
124 } COST_CENTRE_FLAGS;
125
126 /* See Note [Synchronization of flags and base APIs] */
127 typedef struct _PROFILING_FLAGS {
128 uint32_t doHeapProfile;
129 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
130 # define HEAP_BY_CCS 1
131 # define HEAP_BY_MOD 2
132 # define HEAP_BY_DESCR 4
133 # define HEAP_BY_TYPE 5
134 # define HEAP_BY_RETAINER 6
135 # define HEAP_BY_LDV 7
136
137 # define HEAP_BY_CLOSURE_TYPE 8
138
139 Time heapProfileInterval; /* time between samples */
140 uint32_t heapProfileIntervalTicks; /* ticks between samples (derived) */
141 bool includeTSOs;
142
143
144 bool showCCSOnException;
145
146 uint32_t maxRetainerSetSize;
147
148 uint32_t ccsLength;
149
150 const char* modSelector;
151 const char* descrSelector;
152 const char* typeSelector;
153 const char* ccSelector;
154 const char* ccsSelector;
155 const char* retainerSelector;
156 const char* bioSelector;
157
158 } PROFILING_FLAGS;
159
160 #define TRACE_NONE 0
161 #define TRACE_EVENTLOG 1
162 #define TRACE_STDERR 2
163
164 /* See Note [Synchronization of flags and base APIs] */
165 typedef struct _TRACE_FLAGS {
166 int tracing;
167 bool timestamp; /* show timestamp in stderr output */
168 bool scheduler; /* trace scheduler events */
169 bool gc; /* trace GC events */
170 bool sparks_sampled; /* trace spark events by a sampled method */
171 bool sparks_full; /* trace spark events 100% accurately */
172 bool user; /* trace user events (emitted from Haskell code) */
173 } TRACE_FLAGS;
174
175 /* See Note [Synchronization of flags and base APIs] */
176 typedef struct _CONCURRENT_FLAGS {
177 Time ctxtSwitchTime; /* units: TIME_RESOLUTION */
178 int ctxtSwitchTicks; /* derived */
179 } CONCURRENT_FLAGS;
180
181 /*
182 * The tickInterval is the time interval between "ticks", ie.
183 * timer signals (see Timer.{c,h}). It is the frequency at
184 * which we sample CCCS for profiling.
185 *
186 * It is changed by the +RTS -V<secs> flag.
187 */
188 #define DEFAULT_TICK_INTERVAL USToTime(10000)
189
190 /* See Note [Synchronization of flags and base APIs] */
191 typedef struct _MISC_FLAGS {
192 Time tickInterval; /* units: TIME_RESOLUTION */
193 bool install_signal_handlers;
194 bool install_seh_handlers;
195 bool generate_dump_file;
196 bool generate_stack_trace;
197 bool machineReadable;
198 StgWord linkerMemBase; /* address to ask the OS for memory
199 * for the linker, NULL ==> off */
200 } MISC_FLAGS;
201
202 /* See Note [Synchronization of flags and base APIs] */
203 typedef struct _PAR_FLAGS {
204 uint32_t nCapabilities; /* number of threads to run simultaneously */
205 bool migrate; /* migrate threads between capabilities */
206 uint32_t maxLocalSparks;
207 bool parGcEnabled; /* enable parallel GC */
208 uint32_t parGcGen; /* do parallel GC in this generation
209 * and higher only */
210 bool parGcLoadBalancingEnabled;
211 /* enable load-balancing in the
212 * parallel GC */
213 uint32_t parGcLoadBalancingGen;
214 /* do load-balancing in this
215 * generation and higher only */
216
217 uint32_t parGcNoSyncWithIdle;
218 /* if a Capability has been idle for
219 * this many GCs, do not try to wake
220 * it up when doing a
221 * non-load-balancing parallel GC.
222 * (zero disables) */
223
224 uint32_t parGcThreads;
225 /* Use this many threads for parallel
226 * GC (default: use all nNodes). */
227
228 bool setAffinity; /* force thread affinity with CPUs */
229 } PAR_FLAGS;
230
231 /* See Note [Synchronization of flags and base APIs] */
232 typedef struct _TICKY_FLAGS {
233 bool showTickyStats;
234 FILE *tickyFile;
235 } TICKY_FLAGS;
236
237 /* Put them together: */
238
239 /* See Note [Synchronization of flags and base APIs] */
240 typedef struct _RTS_FLAGS {
241 /* The first portion of RTS_FLAGS is invariant. */
242 GC_FLAGS GcFlags;
243 CONCURRENT_FLAGS ConcFlags;
244 MISC_FLAGS MiscFlags;
245 DEBUG_FLAGS DebugFlags;
246 COST_CENTRE_FLAGS CcFlags;
247 PROFILING_FLAGS ProfFlags;
248 TRACE_FLAGS TraceFlags;
249 TICKY_FLAGS TickyFlags;
250 PAR_FLAGS ParFlags;
251 } RTS_FLAGS;
252
253 #if defined(COMPILING_RTS_MAIN)
254 extern DLLIMPORT RTS_FLAGS RtsFlags;
255 #elif IN_STG_CODE
256 /* Hack because the C code generator can't generate '&label'. */
257 extern RTS_FLAGS RtsFlags[];
258 #else
259 extern RTS_FLAGS RtsFlags;
260 #endif
261
262 /*
263 * The printf formats are here, so we are less likely to make
264 * overly-long filenames (with disastrous results). No more than 128
265 * chars, please!
266 */
267
268 #define STATS_FILENAME_MAXLEN 128
269
270 #define GR_FILENAME_FMT "%0.124s.gr"
271 #define HP_FILENAME_FMT "%0.124s.hp"
272 #define LIFE_FILENAME_FMT "%0.122s.life"
273 #define PROF_FILENAME_FMT "%0.122s.prof"
274 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
275 #define QP_FILENAME_FMT "%0.124s.qp"
276 #define STAT_FILENAME_FMT "%0.122s.stat"
277 #define TICKY_FILENAME_FMT "%0.121s.ticky"
278 #define TIME_FILENAME_FMT "%0.122s.time"
279 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
280
281 /* an "int" so as to match normal "argc" */
282 /* Now defined in Stg.h (lib/std/cbits need these too.)
283 extern int prog_argc;
284 extern char **prog_argv;
285 */
286 extern int rts_argc; /* ditto */
287 extern char **rts_argv;