Revert "Batch merge"
[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 char *trace_output; /* output filename for eventlog */
174 } TRACE_FLAGS;
175
176 /* See Note [Synchronization of flags and base APIs] */
177 typedef struct _CONCURRENT_FLAGS {
178 Time ctxtSwitchTime; /* units: TIME_RESOLUTION */
179 int ctxtSwitchTicks; /* derived */
180 } CONCURRENT_FLAGS;
181
182 /*
183 * The tickInterval is the time interval between "ticks", ie.
184 * timer signals (see Timer.{c,h}). It is the frequency at
185 * which we sample CCCS for profiling.
186 *
187 * It is changed by the +RTS -V<secs> flag.
188 */
189 #define DEFAULT_TICK_INTERVAL USToTime(10000)
190
191 /* See Note [Synchronization of flags and base APIs] */
192 typedef struct _MISC_FLAGS {
193 Time tickInterval; /* units: TIME_RESOLUTION */
194 bool install_signal_handlers;
195 bool install_seh_handlers;
196 bool generate_dump_file;
197 bool generate_stack_trace;
198 bool machineReadable;
199 bool internalCounters; /* See Note [Internal Counter Stats] */
200 StgWord linkerMemBase; /* address to ask the OS for memory
201 * for the linker, NULL ==> off */
202 } MISC_FLAGS;
203
204 /* See Note [Synchronization of flags and base APIs] */
205 typedef struct _PAR_FLAGS {
206 uint32_t nCapabilities; /* number of threads to run simultaneously */
207 bool migrate; /* migrate threads between capabilities */
208 uint32_t maxLocalSparks;
209 bool parGcEnabled; /* enable parallel GC */
210 uint32_t parGcGen; /* do parallel GC in this generation
211 * and higher only */
212 bool parGcLoadBalancingEnabled;
213 /* enable load-balancing in the
214 * parallel GC */
215 uint32_t parGcLoadBalancingGen;
216 /* do load-balancing in this
217 * generation and higher only */
218
219 uint32_t parGcNoSyncWithIdle;
220 /* if a Capability has been idle for
221 * this many GCs, do not try to wake
222 * it up when doing a
223 * non-load-balancing parallel GC.
224 * (zero disables) */
225
226 uint32_t parGcThreads;
227 /* Use this many threads for parallel
228 * GC (default: use all nNodes). */
229
230 bool setAffinity; /* force thread affinity with CPUs */
231 } PAR_FLAGS;
232
233 /* See Note [Synchronization of flags and base APIs] */
234 typedef struct _TICKY_FLAGS {
235 bool showTickyStats;
236 FILE *tickyFile;
237 } TICKY_FLAGS;
238
239 /* Put them together: */
240
241 /* See Note [Synchronization of flags and base APIs] */
242 typedef struct _RTS_FLAGS {
243 /* The first portion of RTS_FLAGS is invariant. */
244 GC_FLAGS GcFlags;
245 CONCURRENT_FLAGS ConcFlags;
246 MISC_FLAGS MiscFlags;
247 DEBUG_FLAGS DebugFlags;
248 COST_CENTRE_FLAGS CcFlags;
249 PROFILING_FLAGS ProfFlags;
250 TRACE_FLAGS TraceFlags;
251 TICKY_FLAGS TickyFlags;
252 PAR_FLAGS ParFlags;
253 } RTS_FLAGS;
254
255 #if defined(COMPILING_RTS_MAIN)
256 extern DLLIMPORT RTS_FLAGS RtsFlags;
257 #elif IN_STG_CODE
258 /* Hack because the C code generator can't generate '&label'. */
259 extern RTS_FLAGS RtsFlags[];
260 #else
261 extern RTS_FLAGS RtsFlags;
262 #endif
263
264 /*
265 * The printf formats are here, so we are less likely to make
266 * overly-long filenames (with disastrous results). No more than 128
267 * chars, please!
268 */
269
270 #define STATS_FILENAME_MAXLEN 128
271
272 #define GR_FILENAME_FMT "%0.124s.gr"
273 #define HP_FILENAME_FMT "%0.124s.hp"
274 #define LIFE_FILENAME_FMT "%0.122s.life"
275 #define PROF_FILENAME_FMT "%0.122s.prof"
276 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
277 #define QP_FILENAME_FMT "%0.124s.qp"
278 #define STAT_FILENAME_FMT "%0.122s.stat"
279 #define TICKY_FILENAME_FMT "%0.121s.ticky"
280 #define TIME_FILENAME_FMT "%0.122s.time"
281 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
282
283 /* an "int" so as to match normal "argc" */
284 /* Now defined in Stg.h (lib/std/cbits need these too.)
285 extern int prog_argc;
286 extern char **prog_argv;
287 */
288 extern int rts_argc; /* ditto */
289 extern char **rts_argv;