e67f1765600aaca0de6aa02555aa77894e79e6ce
[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 StgWord heapBase; /* address to ask the OS for memory */
69
70 StgWord allocLimitGrace; /* units: *blocks*
71 * After an AllocationLimitExceeded
72 * exception has been raised, how much
73 * extra space is given to the thread
74 * to handle the exception before we
75 * raise it again.
76 */
77 StgWord heapLimitGrace; /* units: *blocks*
78 * After a HeapOverflow exception has
79 * been raised, how much extra space is
80 * given to the thread to handle the
81 * exception before we raise it again.
82 */
83
84 bool numa; /* Use NUMA */
85 StgWord numaMask;
86 } GC_FLAGS;
87
88 /* See Note [Synchronization of flags and base APIs] */
89 typedef struct _DEBUG_FLAGS {
90 /* flags to control debugging output & extra checking in various subsystems */
91 bool scheduler; /* 's' */
92 bool interpreter; /* 'i' */
93 bool weak; /* 'w' */
94 bool gccafs; /* 'G' */
95 bool gc; /* 'g' */
96 bool block_alloc; /* 'b' */
97 bool sanity; /* 'S' warning: might be expensive! */
98 bool stable; /* 't' */
99 bool prof; /* 'p' */
100 bool linker; /* 'l' the object linker */
101 bool apply; /* 'a' */
102 bool stm; /* 'm' */
103 bool squeeze; /* 'z' stack squeezing & lazy blackholing */
104 bool hpc; /* 'c' coverage */
105 bool sparks; /* 'r' */
106 bool numa; /* '--debug-numa' */
107 bool compact; /* 'C' */
108 } DEBUG_FLAGS;
109
110 /* See Note [Synchronization of flags and base APIs] */
111 typedef struct _COST_CENTRE_FLAGS {
112 uint32_t doCostCentres;
113 # define COST_CENTRES_NONE 0
114 # define COST_CENTRES_SUMMARY 1
115 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
116 # define COST_CENTRES_ALL 3
117 # define COST_CENTRES_JSON 4
118
119 int profilerTicks; /* derived */
120 int msecsPerTick; /* derived */
121 char const *outputFileNameStem;
122 } COST_CENTRE_FLAGS;
123
124 /* See Note [Synchronization of flags and base APIs] */
125 typedef struct _PROFILING_FLAGS {
126 uint32_t doHeapProfile;
127 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
128 # define HEAP_BY_CCS 1
129 # define HEAP_BY_MOD 2
130 # define HEAP_BY_DESCR 4
131 # define HEAP_BY_TYPE 5
132 # define HEAP_BY_RETAINER 6
133 # define HEAP_BY_LDV 7
134
135 # define HEAP_BY_CLOSURE_TYPE 8
136
137 Time heapProfileInterval; /* time between samples */
138 uint32_t heapProfileIntervalTicks; /* ticks between samples (derived) */
139 bool includeTSOs;
140
141
142 bool showCCSOnException;
143
144 uint32_t maxRetainerSetSize;
145
146 uint32_t ccsLength;
147
148 const char* modSelector;
149 const char* descrSelector;
150 const char* typeSelector;
151 const char* ccSelector;
152 const char* ccsSelector;
153 const char* retainerSelector;
154 const char* bioSelector;
155
156 } PROFILING_FLAGS;
157
158 #define TRACE_NONE 0
159 #define TRACE_EVENTLOG 1
160 #define TRACE_STDERR 2
161
162 /* See Note [Synchronization of flags and base APIs] */
163 typedef struct _TRACE_FLAGS {
164 int tracing;
165 bool timestamp; /* show timestamp in stderr output */
166 bool scheduler; /* trace scheduler events */
167 bool gc; /* trace GC events */
168 bool sparks_sampled; /* trace spark events by a sampled method */
169 bool sparks_full; /* trace spark events 100% accurately */
170 bool user; /* trace user events (emitted from Haskell code) */
171 } TRACE_FLAGS;
172
173 /* See Note [Synchronization of flags and base APIs] */
174 typedef struct _CONCURRENT_FLAGS {
175 Time ctxtSwitchTime; /* units: TIME_RESOLUTION */
176 int ctxtSwitchTicks; /* derived */
177 } CONCURRENT_FLAGS;
178
179 /*
180 * The tickInterval is the time interval between "ticks", ie.
181 * timer signals (see Timer.{c,h}). It is the frequency at
182 * which we sample CCCS for profiling.
183 *
184 * It is changed by the +RTS -V<secs> flag.
185 */
186 #define DEFAULT_TICK_INTERVAL USToTime(10000)
187
188 /* See Note [Synchronization of flags and base APIs] */
189 typedef struct _MISC_FLAGS {
190 Time tickInterval; /* units: TIME_RESOLUTION */
191 bool install_signal_handlers;
192 bool install_seh_handlers;
193 bool machineReadable;
194 StgWord linkerMemBase; /* address to ask the OS for memory
195 * for the linker, NULL ==> off */
196 } MISC_FLAGS;
197
198 /* See Note [Synchronization of flags and base APIs] */
199 typedef struct _PAR_FLAGS {
200 uint32_t nCapabilities; /* number of threads to run simultaneously */
201 bool migrate; /* migrate threads between capabilities */
202 uint32_t maxLocalSparks;
203 bool parGcEnabled; /* enable parallel GC */
204 uint32_t parGcGen; /* do parallel GC in this generation
205 * and higher only */
206 bool parGcLoadBalancingEnabled;
207 /* enable load-balancing in the
208 * parallel GC */
209 uint32_t parGcLoadBalancingGen;
210 /* do load-balancing in this
211 * generation and higher only */
212
213 uint32_t parGcNoSyncWithIdle;
214 /* if a Capability has been idle for
215 * this many GCs, do not try to wake
216 * it up when doing a
217 * non-load-balancing parallel GC.
218 * (zero disables) */
219
220 uint32_t parGcThreads;
221 /* Use this many threads for parallel
222 * GC (default: use all nNodes). */
223
224 bool setAffinity; /* force thread affinity with CPUs */
225 } PAR_FLAGS;
226
227 /* See Note [Synchronization of flags and base APIs] */
228 typedef struct _TICKY_FLAGS {
229 bool showTickyStats;
230 FILE *tickyFile;
231 } TICKY_FLAGS;
232
233 /* Put them together: */
234
235 /* See Note [Synchronization of flags and base APIs] */
236 typedef struct _RTS_FLAGS {
237 /* The first portion of RTS_FLAGS is invariant. */
238 GC_FLAGS GcFlags;
239 CONCURRENT_FLAGS ConcFlags;
240 MISC_FLAGS MiscFlags;
241 DEBUG_FLAGS DebugFlags;
242 COST_CENTRE_FLAGS CcFlags;
243 PROFILING_FLAGS ProfFlags;
244 TRACE_FLAGS TraceFlags;
245 TICKY_FLAGS TickyFlags;
246 PAR_FLAGS ParFlags;
247 } RTS_FLAGS;
248
249 #if defined(COMPILING_RTS_MAIN)
250 extern DLLIMPORT RTS_FLAGS RtsFlags;
251 #elif IN_STG_CODE
252 /* Hack because the C code generator can't generate '&label'. */
253 extern RTS_FLAGS RtsFlags[];
254 #else
255 extern RTS_FLAGS RtsFlags;
256 #endif
257
258 /*
259 * The printf formats are here, so we are less likely to make
260 * overly-long filenames (with disastrous results). No more than 128
261 * chars, please!
262 */
263
264 #define STATS_FILENAME_MAXLEN 128
265
266 #define GR_FILENAME_FMT "%0.124s.gr"
267 #define HP_FILENAME_FMT "%0.124s.hp"
268 #define LIFE_FILENAME_FMT "%0.122s.life"
269 #define PROF_FILENAME_FMT "%0.122s.prof"
270 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
271 #define QP_FILENAME_FMT "%0.124s.qp"
272 #define STAT_FILENAME_FMT "%0.122s.stat"
273 #define TICKY_FILENAME_FMT "%0.121s.ticky"
274 #define TIME_FILENAME_FMT "%0.122s.time"
275 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
276
277 /* an "int" so as to match normal "argc" */
278 /* Now defined in Stg.h (lib/std/cbits need these too.)
279 extern int prog_argc;
280 extern char **prog_argv;
281 */
282 extern int rts_argc; /* ditto */
283 extern char **rts_argv;