Flags.h 9.65 KB
Newer Older
Simon Marlow's avatar
Simon Marlow committed
1 2
/* -----------------------------------------------------------------------------
 *
3
 * (c) The GHC Team, 1998-2009
Simon Marlow's avatar
Simon Marlow committed
4 5 6
 *
 * Datatypes that holds the command-line flag settings.
 *
7 8 9
 * Do not #include this file directly: #include "Rts.h" instead.
 *
 * To understand the structure of the RTS headers, see the wiki:
10
 *   http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11
 *
Simon Marlow's avatar
Simon Marlow committed
12 13 14 15 16 17
 * ---------------------------------------------------------------------------*/

#ifndef RTS_FLAGS_H
#define RTS_FLAGS_H

#include <stdio.h>
dobenour's avatar
dobenour committed
18 19 20 21
#include <stdint.h>
#include <stdbool.h>
#include "stg/Types.h"
#include "Time.h"
Simon Marlow's avatar
Simon Marlow committed
22 23 24

/* For defaults, see the @initRtsFlagsDefaults@ routine. */

25 26 27 28 29 30 31 32
/* Note [Synchronization of flags and base APIs]
 *
 * We provide accessors to RTS flags in base. (GHC.RTS module)
 * The API should be updated whenever RTS flags are modified.
 */

/* See Note [Synchronization of flags and base APIs] */
typedef struct _GC_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
33
    FILE   *statsFile;
34
    uint32_t  giveStats;
Simon Marlow's avatar
Simon Marlow committed
35 36 37 38 39 40
#define NO_GC_STATS	 0
#define COLLECT_GC_STATS 1
#define ONELINE_GC_STATS 2
#define SUMMARY_GC_STATS 3
#define VERBOSE_GC_STATS 4

41 42 43 44 45 46 47 48 49 50 51
    uint32_t     maxStkSize;         /* in *words* */
    uint32_t     initialStkSize;     /* in *words* */
    uint32_t     stkChunkSize;       /* in *words* */
    uint32_t     stkChunkBufferSize; /* in *words* */

    uint32_t     maxHeapSize;        /* in *blocks* */
    uint32_t     minAllocAreaSize;   /* in *blocks* */
    uint32_t     largeAllocLim;      /* in *blocks* */
    uint32_t     nurseryChunkSize;   /* in *blocks* */
    uint32_t     minOldGenSize;      /* in *blocks* */
    uint32_t     heapSizeSuggestion; /* in *blocks* */
Ben Gamari's avatar
Ben Gamari committed
52
    bool heapSizeSuggestionAuto;
Simon Marlow's avatar
Simon Marlow committed
53 54 55
    double  oldGenFactor;
    double  pcFreeHeap;

56
    uint32_t     generations;
Ben Gamari's avatar
Ben Gamari committed
57
    bool squeezeUpdFrames;
Simon Marlow's avatar
Simon Marlow committed
58

Ben Gamari's avatar
Ben Gamari committed
59
    bool compact;		/* True <=> "compact all the time" */
Simon Marlow's avatar
Simon Marlow committed
60 61
    double  compactThreshold;

Ben Gamari's avatar
Ben Gamari committed
62
    bool sweep;		/* use "mostly mark-sweep" instead of copying
Simon Marlow's avatar
Simon Marlow committed
63
                                 * for the oldest generation */
Ben Gamari's avatar
Ben Gamari committed
64
    bool ringBell;
Simon Marlow's avatar
Simon Marlow committed
65

Simon Marlow's avatar
Simon Marlow committed
66
    Time    idleGCDelayTime;    /* units: TIME_RESOLUTION */
Ben Gamari's avatar
Ben Gamari committed
67
    bool doIdleGC;
Simon Marlow's avatar
Simon Marlow committed
68 69

    StgWord heapBase;           /* address to ask the OS for memory */
70 71 72 73 74 75 76 77

    StgWord allocLimitGrace;    /* units: *blocks*
                                 * After an AllocationLimitExceeded
                                 * exception has been raised, how much
                                 * extra space is given to the thread
                                 * to handle the exception before we
                                 * raise it again.
                                 */
dobenour's avatar
dobenour committed
78 79 80 81 82 83
    StgWord heapLimitGrace;     /* units: *blocks*
                                 * After a HeapOverflow exception has
                                 * been raised, how much extra space is
                                 * given to the thread to handle the
                                 * exception before we raise it again.
                                 */
Simon Marlow's avatar
Simon Marlow committed
84

Ben Gamari's avatar
Ben Gamari committed
85
    bool numa;                   /* Use NUMA */
Simon Marlow's avatar
Simon Marlow committed
86
    StgWord numaMask;
87
} GC_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
88

89 90
/* See Note [Synchronization of flags and base APIs] */
typedef struct _DEBUG_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
91
    /* flags to control debugging output & extra checking in various subsystems */
Ben Gamari's avatar
Ben Gamari committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    bool scheduler;      /* 's' */
    bool interpreter;    /* 'i' */
    bool weak;           /* 'w' */
    bool gccafs;         /* 'G' */
    bool gc;             /* 'g' */
    bool block_alloc;    /* 'b' */
    bool sanity;         /* 'S'   warning: might be expensive! */
    bool stable;         /* 't' */
    bool prof;           /* 'p' */
    bool linker;         /* 'l'   the object linker */
    bool apply;          /* 'a' */
    bool stm;            /* 'm' */
    bool squeeze;        /* 'z'  stack squeezing & lazy blackholing */
    bool hpc;            /* 'c' coverage */
    bool sparks;         /* 'r' */
    bool numa;           /* '--debug-numa' */
108
    bool compact;        /* 'C' */
109
} DEBUG_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
110

111 112
/* See Note [Synchronization of flags and base APIs] */
typedef struct _COST_CENTRE_FLAGS {
113
    uint32_t    doCostCentres;
114
# define COST_CENTRES_NONE      0
Simon Marlow's avatar
Simon Marlow committed
115 116 117
# define COST_CENTRES_SUMMARY	1
# define COST_CENTRES_VERBOSE	2 /* incl. serial time profile */
# define COST_CENTRES_ALL	3
Ben Gamari's avatar
Ben Gamari committed
118
# define COST_CENTRES_JSON      4
Simon Marlow's avatar
Simon Marlow committed
119 120 121

    int	    profilerTicks;   /* derived */
    int	    msecsPerTick;    /* derived */
122
} COST_CENTRE_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
123

124 125
/* See Note [Synchronization of flags and base APIs] */
typedef struct _PROFILING_FLAGS {
126
    uint32_t doHeapProfile;
Simon Marlow's avatar
Simon Marlow committed
127 128 129 130 131 132 133 134 135 136
# define NO_HEAP_PROFILING	0	/* N.B. Used as indexes into arrays */
# define HEAP_BY_CCS		1
# define HEAP_BY_MOD		2
# define HEAP_BY_DESCR		4
# define HEAP_BY_TYPE		5
# define HEAP_BY_RETAINER       6
# define HEAP_BY_LDV            7

# define HEAP_BY_CLOSURE_TYPE   8

137 138
    Time        heapProfileInterval; /* time between samples */
    uint32_t    heapProfileIntervalTicks; /* ticks between samples (derived) */
Ben Gamari's avatar
Ben Gamari committed
139
    bool        includeTSOs;
Simon Marlow's avatar
Simon Marlow committed
140 141


Ben Gamari's avatar
Ben Gamari committed
142
    bool		showCCSOnException;
Simon Marlow's avatar
Simon Marlow committed
143

144
    uint32_t    maxRetainerSetSize;
Simon Marlow's avatar
Simon Marlow committed
145

146
    uint32_t    ccsLength;
Simon Marlow's avatar
Simon Marlow committed
147

Ben Gamari's avatar
Ben Gamari committed
148 149 150 151 152 153 154
    const char*         modSelector;
    const char*         descrSelector;
    const char*         typeSelector;
    const char*         ccSelector;
    const char*         ccsSelector;
    const char*         retainerSelector;
    const char*         bioSelector;
Simon Marlow's avatar
Simon Marlow committed
155

156
} PROFILING_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
157

158 159 160 161
#define TRACE_NONE      0
#define TRACE_EVENTLOG  1
#define TRACE_STDERR    2

162 163
/* See Note [Synchronization of flags and base APIs] */
typedef struct _TRACE_FLAGS {
164
    int tracing;
Ben Gamari's avatar
Ben Gamari committed
165 166 167 168 169 170
    bool timestamp;      /* show timestamp in stderr output */
    bool scheduler;      /* trace scheduler events */
    bool gc;             /* trace GC events */
    bool sparks_sampled; /* trace spark events by a sampled method */
    bool sparks_full;    /* trace spark events 100% accurately */
    bool user;           /* trace user events (emitted from Haskell code) */
171
} TRACE_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
172

173 174
/* See Note [Synchronization of flags and base APIs] */
typedef struct _CONCURRENT_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
175 176
    Time ctxtSwitchTime;         /* units: TIME_RESOLUTION */
    int ctxtSwitchTicks;         /* derived */
177
} CONCURRENT_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
178

Simon Marlow's avatar
Simon Marlow committed
179 180 181 182 183 184 185 186 187
/*
 * The tickInterval is the time interval between "ticks", ie.
 * timer signals (see Timer.{c,h}).  It is the frequency at
 * which we sample CCCS for profiling.
 *
 * It is changed by the +RTS -V<secs> flag.
 */
#define DEFAULT_TICK_INTERVAL USToTime(10000)

188 189
/* See Note [Synchronization of flags and base APIs] */
typedef struct _MISC_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
190
    Time    tickInterval;        /* units: TIME_RESOLUTION */
Ben Gamari's avatar
Ben Gamari committed
191 192
    bool install_signal_handlers;
    bool machineReadable;
Simon Marlow's avatar
Simon Marlow committed
193 194
    StgWord linkerMemBase;       /* address to ask the OS for memory
                                  * for the linker, NULL ==> off */
195
} MISC_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
196

197 198
/* See Note [Synchronization of flags and base APIs] */
typedef struct _PAR_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
199
  uint32_t       nCapabilities;  /* number of threads to run simultaneously */
Ben Gamari's avatar
Ben Gamari committed
200
  bool           migrate;        /* migrate threads between capabilities */
201
  uint32_t       maxLocalSparks;
Ben Gamari's avatar
Ben Gamari committed
202
  bool           parGcEnabled;   /* enable parallel GC */
203
  uint32_t       parGcGen;       /* do parallel GC in this generation
Simon Marlow's avatar
Simon Marlow committed
204
                                  * and higher only */
Ben Gamari's avatar
Ben Gamari committed
205
  bool           parGcLoadBalancingEnabled;
206 207
                                 /* enable load-balancing in the
                                  * parallel GC */
208
  uint32_t       parGcLoadBalancingGen;
209 210
                                 /* do load-balancing in this
                                  * generation and higher only */
211

212
  uint32_t       parGcNoSyncWithIdle;
213 214 215 216 217 218
                                 /* if a Capability has been idle for
                                  * this many GCs, do not try to wake
                                  * it up when doing a
                                  * non-load-balancing parallel GC.
                                  * (zero disables) */

219
  uint32_t       parGcThreads;
220 221 222
                                 /* Use this many threads for parallel
                                  * GC (default: use all nNodes). */

Ben Gamari's avatar
Ben Gamari committed
223
  bool           setAffinity;    /* force thread affinity with CPUs */
224
} PAR_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
225

226 227
/* See Note [Synchronization of flags and base APIs] */
typedef struct _TICKY_FLAGS {
Ben Gamari's avatar
Ben Gamari committed
228
    bool showTickyStats;
Simon Marlow's avatar
Simon Marlow committed
229
    FILE   *tickyFile;
230
} TICKY_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
231 232 233

/* Put them together: */

234
/* See Note [Synchronization of flags and base APIs] */
Simon Marlow's avatar
Simon Marlow committed
235 236
typedef struct _RTS_FLAGS {
    /* The first portion of RTS_FLAGS is invariant. */
237 238 239 240 241 242 243 244 245
    GC_FLAGS	      GcFlags;
    CONCURRENT_FLAGS  ConcFlags;
    MISC_FLAGS        MiscFlags;
    DEBUG_FLAGS	      DebugFlags;
    COST_CENTRE_FLAGS CcFlags;
    PROFILING_FLAGS   ProfFlags;
    TRACE_FLAGS       TraceFlags;
    TICKY_FLAGS	      TickyFlags;
    PAR_FLAGS	      ParFlags;
Simon Marlow's avatar
Simon Marlow committed
246 247 248 249 250 251 252 253 254 255 256 257 258 259
} RTS_FLAGS;

#ifdef COMPILING_RTS_MAIN
extern DLLIMPORT RTS_FLAGS RtsFlags;
#elif IN_STG_CODE
/* Hack because the C code generator can't generate '&label'. */
extern RTS_FLAGS RtsFlags[];
#else
extern RTS_FLAGS RtsFlags;
#endif

/*
 * The printf formats are here, so we are less likely to make
 * overly-long filenames (with disastrous results).  No more than 128
260
 * chars, please!
Simon Marlow's avatar
Simon Marlow committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
 */

#define STATS_FILENAME_MAXLEN	128

#define GR_FILENAME_FMT		"%0.124s.gr"
#define GR_FILENAME_FMT_GUM	"%0.120s.%03d.%s"
#define HP_FILENAME_FMT		"%0.124s.hp"
#define LIFE_FILENAME_FMT	"%0.122s.life"
#define PROF_FILENAME_FMT	"%0.122s.prof"
#define PROF_FILENAME_FMT_GUM	"%0.118s.%03d.prof"
#define QP_FILENAME_FMT		"%0.124s.qp"
#define STAT_FILENAME_FMT	"%0.122s.stat"
#define TICKY_FILENAME_FMT	"%0.121s.ticky"
#define TIME_FILENAME_FMT	"%0.122s.time"
#define TIME_FILENAME_FMT_GUM	"%0.118s.%03d.time"

/* an "int" so as to match normal "argc" */
/* Now defined in Stg.h (lib/std/cbits need these too.)
extern int     prog_argc;
extern char  **prog_argv;
*/
282 283
extern int      rts_argc;  /* ditto */
extern char   **rts_argv;
Simon Marlow's avatar
Simon Marlow committed
284 285

#endif	/* RTS_FLAGS_H */