FIX #4826 partially: Change -f to -? in User Guide section F4.16
[ghc-hetmet.git] / docs / users_guide / runtime_control.xml
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <sect1 id="runtime-control">
3   <title>Running a compiled program</title>
4
5   <indexterm><primary>runtime control of Haskell programs</primary></indexterm>
6   <indexterm><primary>running, compiled program</primary></indexterm>
7   <indexterm><primary>RTS options</primary></indexterm>
8
9   <para>To make an executable program, the GHC system compiles your
10   code and then links it with a non-trivial runtime system (RTS),
11   which handles storage management, profiling, etc.</para>
12
13   <para>If you use the <literal>-rtsopts</literal> flag when linking,
14   you have some control over the behaviour of the RTS, by giving
15   special command-line arguments to your program.</para>
16
17   <para>When your Haskell program starts up, its RTS extracts
18   command-line arguments bracketed between
19   <option>+RTS</option><indexterm><primary><option>+RTS</option></primary></indexterm>
20   and
21   <option>-RTS</option><indexterm><primary><option>-RTS</option></primary></indexterm>
22   as its own.  For example:</para>
23
24 <screen>
25 % ./a.out -f +RTS -p -S -RTS -h foo bar
26 </screen>
27
28   <para>The RTS will snaffle <option>-p</option> <option>-S</option>
29   for itself, and the remaining arguments <literal>-f -h foo bar</literal>
30   will be handed to your program if/when it calls
31   <function>System.getArgs</function>.</para>
32
33   <para>No <option>-RTS</option> option is required if the
34   runtime-system options extend to the end of the command line, as in
35   this example:</para>
36
37 <screen>
38 % hls -ltr /usr/etc +RTS -A5m
39 </screen>
40
41   <para>If you absolutely positively want all the rest of the options
42   in a command line to go to the program (and not the RTS), use a
43   <option>&ndash;&ndash;RTS</option><indexterm><primary><option>--RTS</option></primary></indexterm>.</para>
44
45   <para>As always, for RTS options that take
46   <replaceable>size</replaceable>s: If the last character of
47   <replaceable>size</replaceable> is a K or k, multiply by 1000; if an
48   M or m, by 1,000,000; if a G or G, by 1,000,000,000.  (And any
49   wraparound in the counters is <emphasis>your</emphasis>
50   fault!)</para>
51
52   <para>Giving a <literal>+RTS -?</literal>
53   <indexterm><primary><option>-?</option></primary><secondary>RTS option</secondary></indexterm> option
54   will print out the RTS options actually available in your program
55   (which vary, depending on how you compiled).</para>
56
57   <para>NOTE: since GHC is itself compiled by GHC, you can change RTS
58   options in the compiler using the normal
59   <literal>+RTS ... -RTS</literal>
60   combination.  eg. to increase the maximum heap
61   size for a compilation to 128M, you would add
62   <literal>+RTS -M128m -RTS</literal>
63   to the command line.</para>
64
65   <sect2 id="rts-options-environment">
66     <title>Setting global RTS options</title>
67
68     <indexterm><primary>RTS options</primary><secondary>from the environment</secondary></indexterm>
69     <indexterm><primary>environment variable</primary><secondary>for
70     setting RTS options</secondary></indexterm>
71
72     <para>When the <literal>-rtsopts</literal> flag is used when linking,
73     RTS options are also taken from the environment variable
74     <envar>GHCRTS</envar><indexterm><primary><envar>GHCRTS</envar></primary>
75       </indexterm>.  For example, to set the maximum heap size
76     to 128M for all GHC-compiled programs (using an
77     <literal>sh</literal>-like shell):</para>
78
79 <screen>
80    GHCRTS='-M128m'
81    export GHCRTS
82 </screen>
83
84     <para>RTS options taken from the <envar>GHCRTS</envar> environment
85     variable can be overridden by options given on the command
86     line.</para>
87
88   </sect2>
89
90   <sect2 id="rts-options-misc">
91     <title>Miscellaneous RTS options</title>
92
93     <variablelist>
94      <varlistentry>
95        <term><option>-V<replaceable>secs</replaceable></option>
96        <indexterm><primary><option>-V</option></primary><secondary>RTS
97        option</secondary></indexterm></term>
98        <listitem>
99          <para>Sets the interval that the RTS clock ticks at.  The
100          runtime uses a single timer signal to count ticks; this timer
101          signal is used to control the context switch timer (<xref
102          linkend="using-concurrent" />) and the heap profiling
103          timer <xref linkend="rts-options-heap-prof" />.  Also, the
104          time profiler uses the RTS timer signal directly to record
105          time profiling samples.</para>
106
107          <para>Normally, setting the <option>-V</option> option
108          directly is not necessary: the resolution of the RTS timer is
109          adjusted automatically if a short interval is requested with
110          the <option>-C</option> or <option>-i</option> options.
111          However, setting <option>-V</option> is required in order to
112          increase the resolution of the time profiler.</para>
113
114          <para>Using a value of zero disables the RTS clock
115          completely, and has the effect of disabling timers that
116          depend on it: the context switch timer and the heap profiling
117          timer.  Context switches will still happen, but
118          deterministically and at a rate much faster than normal.
119          Disabling the interval timer is useful for debugging, because
120          it eliminates a source of non-determinism at runtime.</para>
121        </listitem>
122      </varlistentry>
123
124      <varlistentry>
125        <term><option>--install-signal-handlers=<replaceable>yes|no</replaceable></option>
126        <indexterm><primary><option>--install-signal-handlers</option></primary><secondary>RTS
127        option</secondary></indexterm></term>
128        <listitem>
129          <para>If yes (the default), the RTS installs signal handlers to catch
130          things like ctrl-C. This option is primarily useful for when
131          you are using the Haskell code as a DLL, and want to set your
132          own signal handlers.</para>
133
134          <para>Note that even
135            with <option>--install-signal-handlers=no</option>, the RTS
136            interval timer signal is still enabled.  The timer signal
137            is either SIGVTALRM or SIGALRM, depending on the RTS
138            configuration and OS capabilities.  To disable the timer
139            signal, use the <literal>-V0</literal> RTS option (see
140            above).
141          </para>
142        </listitem>
143      </varlistentry>
144
145      <varlistentry>
146        <term><option>-xm<replaceable>address</replaceable></option>
147        <indexterm><primary><option>-xm</option></primary><secondary>RTS
148        option</secondary></indexterm></term>
149        <listitem>
150          <para>
151            WARNING: this option is for working around memory
152            allocation problems only.  Do not use unless GHCi fails
153            with a message like &ldquo;<literal>failed to mmap() memory below 2Gb</literal>&rdquo;.  If you need to use this option to get GHCi working
154            on your machine, please file a bug.
155          </para>
156          
157          <para>
158            On 64-bit machines, the RTS needs to allocate memory in the
159            low 2Gb of the address space.  Support for this across
160            different operating systems is patchy, and sometimes fails.
161            This option is there to give the RTS a hint about where it
162            should be able to allocate memory in the low 2Gb of the
163            address space.  For example, <literal>+RTS -xm20000000
164            -RTS</literal> would hint that the RTS should allocate
165            starting at the 0.5Gb mark.  The default is to use the OS's
166            built-in support for allocating memory in the low 2Gb if
167            available (e.g. <literal>mmap</literal>
168            with <literal>MAP_32BIT</literal> on Linux), or
169            otherwise <literal>-xm40000000</literal>.
170          </para>
171        </listitem>
172      </varlistentry>
173     </variablelist>
174   </sect2>
175
176   <sect2 id="rts-options-gc">
177     <title>RTS options to control the garbage collector</title>
178
179     <indexterm><primary>garbage collector</primary><secondary>options</secondary></indexterm>
180     <indexterm><primary>RTS options</primary><secondary>garbage collection</secondary></indexterm>
181
182     <para>There are several options to give you precise control over
183     garbage collection.  Hopefully, you won't need any of these in
184     normal operation, but there are several things that can be tweaked
185     for maximum performance.</para>
186
187     <variablelist>
188
189       <varlistentry>
190         <term>
191           <option>-A</option><replaceable>size</replaceable>
192           <indexterm><primary><option>-A</option></primary><secondary>RTS option</secondary></indexterm>
193           <indexterm><primary>allocation area, size</primary></indexterm>
194         </term>
195         <listitem>
196           <para>&lsqb;Default: 512k&rsqb; Set the allocation area size
197           used by the garbage collector.  The allocation area
198           (actually generation 0 step 0) is fixed and is never resized
199           (unless you use <option>-H</option>, below).</para>
200
201           <para>Increasing the allocation area size may or may not
202           give better performance (a bigger allocation area means
203           worse cache behaviour but fewer garbage collections and less
204           promotion).</para>
205
206           <para>With only 1 generation (<option>-G1</option>) the
207           <option>-A</option> option specifies the minimum allocation
208           area, since the actual size of the allocation area will be
209           resized according to the amount of data in the heap (see
210           <option>-F</option>, below).</para>
211         </listitem>
212       </varlistentry>
213
214       <varlistentry>
215         <term>
216           <option>-c</option>
217           <indexterm><primary><option>-c</option></primary><secondary>RTS option</secondary></indexterm>
218           <indexterm><primary>garbage collection</primary><secondary>compacting</secondary></indexterm>
219           <indexterm><primary>compacting garbage collection</primary></indexterm>
220         </term>
221         <listitem>
222           <para>Use a compacting algorithm for collecting the oldest
223           generation.  By default, the oldest generation is collected
224           using a copying algorithm; this option causes it to be
225           compacted in-place instead.  The compaction algorithm is
226           slower than the copying algorithm, but the savings in memory
227           use can be considerable.</para>
228
229           <para>For a given heap size (using the <option>-H</option>
230           option), compaction can in fact reduce the GC cost by
231           allowing fewer GCs to be performed.  This is more likely
232           when the ratio of live data to heap size is high, say
233           &gt;30&percnt;.</para>
234
235           <para>NOTE: compaction doesn't currently work when a single
236           generation is requested using the <option>-G1</option>
237           option.</para>
238         </listitem>
239       </varlistentry>
240
241       <varlistentry>
242         <term><option>-c</option><replaceable>n</replaceable></term>
243
244         <listitem>
245           <para>&lsqb;Default: 30&rsqb; Automatically enable
246           compacting collection when the live data exceeds
247           <replaceable>n</replaceable>&percnt; of the maximum heap size
248           (see the <option>-M</option> option).  Note that the maximum
249           heap size is unlimited by default, so this option has no
250           effect unless the maximum heap size is set with
251           <option>-M</option><replaceable>size</replaceable>. </para>
252         </listitem>
253       </varlistentry>
254
255       <varlistentry>
256         <term>
257           <option>-F</option><replaceable>factor</replaceable>
258           <indexterm><primary><option>-F</option></primary><secondary>RTS option</secondary></indexterm>
259           <indexterm><primary>heap size, factor</primary></indexterm>
260         </term>
261         <listitem>
262
263           <para>&lsqb;Default: 2&rsqb; This option controls the amount
264           of memory reserved for the older generations (and in the
265           case of a two space collector the size of the allocation
266           area) as a factor of the amount of live data.  For example,
267           if there was 2M of live data in the oldest generation when
268           we last collected it, then by default we'll wait until it
269           grows to 4M before collecting it again.</para>
270
271           <para>The default seems to work well here.  If you have
272           plenty of memory, it is usually better to use
273           <option>-H</option><replaceable>size</replaceable> than to
274           increase
275           <option>-F</option><replaceable>factor</replaceable>.</para>
276
277           <para>The <option>-F</option> setting will be automatically
278           reduced by the garbage collector when the maximum heap size
279           (the <option>-M</option><replaceable>size</replaceable>
280           setting) is approaching.</para>
281         </listitem>
282       </varlistentry>
283
284       <varlistentry>
285         <term>
286           <option>-G</option><replaceable>generations</replaceable>
287           <indexterm><primary><option>-G</option></primary><secondary>RTS option</secondary></indexterm>
288           <indexterm><primary>generations, number of</primary></indexterm>
289         </term>
290         <listitem>
291           <para>&lsqb;Default: 2&rsqb; Set the number of generations
292           used by the garbage collector.  The default of 2 seems to be
293           good, but the garbage collector can support any number of
294           generations.  Anything larger than about 4 is probably not a
295           good idea unless your program runs for a
296           <emphasis>long</emphasis> time, because the oldest
297           generation will hardly ever get collected.</para>
298
299           <para>Specifying 1 generation with <option>+RTS -G1</option>
300           gives you a simple 2-space collector, as you would expect.
301           In a 2-space collector, the <option>-A</option> option (see
302           above) specifies the <emphasis>minimum</emphasis> allocation
303           area size, since the allocation area will grow with the
304           amount of live data in the heap.  In a multi-generational
305           collector the allocation area is a fixed size (unless you
306           use the <option>-H</option> option, see below).</para>
307         </listitem>
308       </varlistentry>
309
310       <varlistentry>
311         <term>
312           <option>-qg<optional><replaceable>gen</replaceable></optional></option>
313           <indexterm><primary><option>-qg</option><secondary>RTS
314           option</secondary></primary></indexterm>
315         </term>
316         <listitem>
317           <para>&lsqb;New in GHC 6.12.1&rsqb; &lsqb;Default: 0&rsqb;
318             Use parallel GC in
319             generation <replaceable>gen</replaceable> and higher.
320             Omitting <replaceable>gen</replaceable> turns off the
321             parallel GC completely, reverting to sequential GC.</para>
322           
323           <para>The default parallel GC settings are usually suitable
324             for parallel programs (i.e. those
325             using <literal>par</literal>, Strategies, or with multiple
326             threads).  However, it is sometimes beneficial to enable
327             the parallel GC for a single-threaded sequential program
328             too, especially if the program has a large amount of heap
329             data and GC is a significant fraction of runtime.  To use
330             the parallel GC in a sequential program, enable the
331             parallel runtime with a suitable <literal>-N</literal>
332             option, and additionally it might be beneficial to
333             restrict parallel GC to the old generation
334             with <literal>-qg1</literal>.</para>
335         </listitem>
336       </varlistentry>        
337
338       <varlistentry>
339         <term>
340           <option>-qb<optional><replaceable>gen</replaceable></optional></option>
341           <indexterm><primary><option>-qb</option><secondary>RTS
342           option</secondary></primary></indexterm>
343         </term>
344         <listitem>
345           <para>
346             &lsqb;New in GHC 6.12.1&rsqb; &lsqb;Default: 1&rsqb; Use
347             load-balancing in the parallel GC in
348             generation <replaceable>gen</replaceable> and higher.
349             Omitting <replaceable>gen</replaceable> disables
350             load-balancing entirely.</para>
351           
352           <para>
353             Load-balancing shares out the work of GC between the
354             available cores.  This is a good idea when the heap is
355             large and we need to parallelise the GC work, however it
356             is also pessimal for the short young-generation
357             collections in a parallel program, because it can harm
358             locality by moving data from the cache of the CPU where is
359             it being used to the cache of another CPU.  Hence the
360             default is to do load-balancing only in the
361             old-generation.  In fact, for a parallel program it is
362             sometimes beneficial to disable load-balancing entirely
363             with <literal>-qb</literal>.
364           </para>
365         </listitem>
366       </varlistentry>
367
368       <varlistentry>
369         <term>
370           <option>-H</option><replaceable>size</replaceable>
371           <indexterm><primary><option>-H</option></primary><secondary>RTS option</secondary></indexterm>
372           <indexterm><primary>heap size, suggested</primary></indexterm>
373         </term>
374         <listitem>
375           <para>&lsqb;Default: 0&rsqb; This option provides a
376           &ldquo;suggested heap size&rdquo; for the garbage collector.  The
377           garbage collector will use about this much memory until the
378           program residency grows and the heap size needs to be
379           expanded to retain reasonable performance.</para>
380
381           <para>By default, the heap will start small, and grow and
382           shrink as necessary.  This can be bad for performance, so if
383           you have plenty of memory it's worthwhile supplying a big
384           <option>-H</option><replaceable>size</replaceable>.  For
385           improving GC performance, using
386           <option>-H</option><replaceable>size</replaceable> is
387           usually a better bet than
388           <option>-A</option><replaceable>size</replaceable>.</para>
389         </listitem>
390       </varlistentry>
391
392       <varlistentry>
393         <term>
394           <option>-I</option><replaceable>seconds</replaceable>
395           <indexterm><primary><option>-I</option></primary>
396             <secondary>RTS option</secondary>
397           </indexterm>
398           <indexterm><primary>idle GC</primary>
399           </indexterm>
400           </term>
401         <listitem>
402           <para>(default: 0.3) In the threaded and SMP versions of the RTS (see
403             <option>-threaded</option>, <xref linkend="options-linker" />), a
404             major GC is automatically performed if the runtime has been idle
405             (no Haskell computation has been running) for a period of time.
406             The amount of idle time which must pass before a GC is performed is
407             set by the <option>-I</option><replaceable>seconds</replaceable>
408             option.  Specifying <option>-I0</option> disables the idle GC.</para>
409
410           <para>For an interactive application, it is probably a good idea to
411             use the idle GC, because this will allow finalizers to run and
412             deadlocked threads to be detected in the idle time when no Haskell
413             computation is happening.  Also, it will mean that a GC is less
414             likely to happen when the application is busy, and so
415             responsiveness may be improved.   However, if the amount of live data in
416             the heap is particularly large, then the idle GC can cause a
417             significant delay, and too small an interval could adversely affect
418             interactive responsiveness.</para>
419
420           <para>This is an experimental feature, please let us know if it
421             causes problems and/or could benefit from further tuning.</para>
422         </listitem>
423       </varlistentry>
424
425       <varlistentry>
426         <term>
427          <option>-ki</option><replaceable>size</replaceable>
428          <indexterm><primary><option>-k</option></primary><secondary>RTS option</secondary></indexterm>
429          <indexterm><primary>stack, initial size</primary></indexterm>
430         </term>
431         <listitem>
432           <para>
433             &lsqb;Default: 1k&rsqb; Set the initial stack size for new
434             threads.  (Note: this flag used to be
435             simply <option>-k</option>, but was renamed
436             to <option>-ki</option> in GHC 7.2.1.  The old name is
437             still accepted for backwards compatibility, but that may
438             be removed in a future version).
439           </para>
440
441           <para>
442             Thread stacks (including the main thread's stack) live on
443             the heap.  As the stack grows, new stack chunks are added
444             as required; if the stack shrinks again, these extra stack
445             chunks are reclaimed by the garbage collector.  The
446             default initial stack size is deliberately small, in order
447             to keep the time and space overhead for thread creation to
448             a minimum, and to make it practical to spawn threads for
449             even tiny pieces of work.
450           </para>
451         </listitem>
452       </varlistentry>
453
454       <varlistentry>
455         <term>
456           <option>-kc</option><replaceable>size</replaceable>
457           <indexterm><primary><option>-kc</option></primary><secondary>RTS
458           option</secondary></indexterm>
459           <indexterm><primary>stack</primary><secondary>chunk size</secondary></indexterm>
460         </term>
461         <listitem>
462           <para>
463             &lsqb;Default: 32k&rsqb; Set the size of &ldquo;stack
464             chunks&rdquo;.  When a thread's current stack overflows, a
465             new stack chunk is created and added to the thread's
466             stack, until the limit set by <option>-K</option> is
467             reached.
468           </para>
469
470           <para>
471             The advantage of smaller stack chunks is that the garbage
472             collector can avoid traversing stack chunks if they are
473             known to be unmodified since the last collection, so
474             reducing the chunk size means that the garbage collector
475             can identify more stack as unmodified, and the GC overhead
476             might be reduced.  On the other hand, making stack chunks
477             too small adds some overhead as there will be more
478             overflow/underflow between chunks.  The default setting of
479             32k appears to be a reasonable compromise in most cases.
480           </para>
481         </listitem>
482       </varlistentry>
483
484       <varlistentry>
485         <term>
486           <option>-kb</option><replaceable>size</replaceable>
487           <indexterm><primary><option>-kc</option></primary><secondary>RTS
488           option</secondary></indexterm>
489           <indexterm><primary>stack</primary><secondary>chunk buffer size</secondary></indexterm>
490         </term>
491         <listitem>
492           <para>
493             &lsqb;Default: 1k&rsqb; Sets the stack chunk buffer size.
494             When a stack chunk overflows and a new stack chunk is
495             created, some of the data from the previous stack chunk is
496             moved into the new chunk, to avoid an immediate underflow
497             and repeated overflow/underflow at the boundary.  The
498             amount of stack moved is set by the <option>-kb</option>
499             option.
500           </para>
501           <para>
502             Note that to avoid wasting space, this value should
503             typically be less than 10&percnt; of the size of a stack
504             chunk (<option>-kc</option>), because in a chain of stack
505             chunks, each chunk will have a gap of unused space of this
506             size.
507           </para>
508         </listitem>
509       </varlistentry>
510
511       <varlistentry>
512         <term>
513           <option>-K</option><replaceable>size</replaceable>
514           <indexterm><primary><option>-K</option></primary><secondary>RTS option</secondary></indexterm>
515           <indexterm><primary>stack, maximum size</primary></indexterm>
516         </term>
517         <listitem>
518           <para>&lsqb;Default: 8M&rsqb; Set the maximum stack size for
519           an individual thread to <replaceable>size</replaceable>
520           bytes.  If the thread attempts to exceed this limit, it will
521             be send the <literal>StackOverflow</literal> exception.
522           </para>
523           <para>
524             This option is there mainly to stop the program eating up
525             all the available memory in the machine if it gets into an
526             infinite loop.
527           </para>
528         </listitem>
529       </varlistentry>
530
531       <varlistentry>
532         <term>
533           <option>-m</option><replaceable>n</replaceable>
534           <indexterm><primary><option>-m</option></primary><secondary>RTS option</secondary></indexterm>
535           <indexterm><primary>heap, minimum free</primary></indexterm>
536         </term>
537         <listitem>
538           <para>Minimum &percnt; <replaceable>n</replaceable> of heap
539           which must be available for allocation.  The default is
540           3&percnt;.</para>
541         </listitem>
542       </varlistentry>
543
544       <varlistentry>
545         <term>
546           <option>-M</option><replaceable>size</replaceable>
547           <indexterm><primary><option>-M</option></primary><secondary>RTS option</secondary></indexterm>
548           <indexterm><primary>heap size, maximum</primary></indexterm>
549         </term>
550         <listitem>
551           <para>&lsqb;Default: unlimited&rsqb; Set the maximum heap size to
552           <replaceable>size</replaceable> bytes.  The heap normally
553           grows and shrinks according to the memory requirements of
554           the program.  The only reason for having this option is to
555           stop the heap growing without bound and filling up all the
556           available swap space, which at the least will result in the
557           program being summarily killed by the operating
558           system.</para>
559
560           <para>The maximum heap size also affects other garbage
561           collection parameters: when the amount of live data in the
562           heap exceeds a certain fraction of the maximum heap size,
563           compacting collection will be automatically enabled for the
564           oldest generation, and the <option>-F</option> parameter
565           will be reduced in order to avoid exceeding the maximum heap
566           size.</para>
567         </listitem>
568       </varlistentry>
569
570       <varlistentry>
571         <term>
572           <option>-t</option><optional><replaceable>file</replaceable></optional>
573           <indexterm><primary><option>-t</option></primary><secondary>RTS option</secondary></indexterm>
574         </term>
575         <term>
576           <option>-s</option><optional><replaceable>file</replaceable></optional>
577           <indexterm><primary><option>-s</option></primary><secondary>RTS option</secondary></indexterm>
578         </term>
579         <term>
580           <option>-S</option><optional><replaceable>file</replaceable></optional>
581           <indexterm><primary><option>-S</option></primary><secondary>RTS option</secondary></indexterm>
582         </term>
583         <term>
584           <option>--machine-readable</option>
585           <indexterm><primary><option>--machine-readable</option></primary><secondary>RTS option</secondary></indexterm>
586         </term>
587         <listitem>
588           <para>These options produce runtime-system statistics, such
589           as the amount of time spent executing the program and in the
590           garbage collector, the amount of memory allocated, the
591           maximum size of the heap, and so on.  The three
592           variants give different levels of detail:
593           <option>-t</option> produces a single line of output in the
594           same format as GHC's <option>-Rghc-timing</option> option,
595           <option>-s</option> produces a more detailed summary at the
596           end of the program, and <option>-S</option> additionally
597           produces information about each and every garbage
598           collection.</para>
599
600           <para>The output is placed in
601           <replaceable>file</replaceable>.  If
602           <replaceable>file</replaceable> is omitted, then the output
603           is sent to <constant>stderr</constant>.</para>
604
605     <para>
606         If you use the <literal>-t</literal> flag then, when your
607         program finishes, you will see something like this:
608     </para>
609
610 <programlisting>
611 &lt;&lt;ghc: 36169392 bytes, 69 GCs, 603392/1065272 avg/max bytes residency (2 samples), 3M in use, 0.00 INIT (0.00 elapsed), 0.02 MUT (0.02 elapsed), 0.07 GC (0.07 elapsed) :ghc&gt;&gt;
612 </programlisting>
613
614     <para>
615         This tells you:
616     </para>
617
618     <itemizedlist>
619       <listitem>
620         <para>
621           The total number of bytes allocated by the program over the
622           whole run.
623         </para>
624       </listitem>
625       <listitem>
626         <para>
627           The total number of garbage collections performed.
628         </para>
629       </listitem>
630       <listitem>
631         <para>
632           The average and maximum "residency", which is the amount of
633           live data in bytes.  The runtime can only determine the
634           amount of live data during a major GC, which is why the
635           number of samples corresponds to the number of major GCs
636           (and is usually relatively small).  To get a better picture
637           of the heap profile of your program, use
638           the <option>-hT</option> RTS option
639           (<xref linkend="rts-profiling" />).
640         </para>
641       </listitem>
642       <listitem>
643         <para>
644           The peak memory the RTS has allocated from the OS. 
645         </para>
646       </listitem>
647       <listitem>
648         <para>
649           The amount of CPU time and elapsed wall clock time while
650           initialising the runtime system (INIT), running the program
651           itself (MUT, the mutator), and garbage collecting (GC).
652         </para>
653       </listitem>
654     </itemizedlist>
655
656     <para>
657         You can also get this in a more future-proof, machine readable
658         format, with <literal>-t --machine-readable</literal>:
659     </para>
660
661 <programlisting>
662  [("bytes allocated", "36169392")
663  ,("num_GCs", "69")
664  ,("average_bytes_used", "603392")
665  ,("max_bytes_used", "1065272")
666  ,("num_byte_usage_samples", "2")
667  ,("peak_megabytes_allocated", "3")
668  ,("init_cpu_seconds", "0.00")
669  ,("init_wall_seconds", "0.00")
670  ,("mutator_cpu_seconds", "0.02")
671  ,("mutator_wall_seconds", "0.02")
672  ,("GC_cpu_seconds", "0.07")
673  ,("GC_wall_seconds", "0.07")
674  ]
675 </programlisting>
676
677     <para>
678         If you use the <literal>-s</literal> flag then, when your
679         program finishes, you will see something like this (the exact
680         details will vary depending on what sort of RTS you have, e.g.
681         you will only see profiling data if your RTS is compiled for
682         profiling):
683     </para>
684
685 <programlisting>
686       36,169,392 bytes allocated in the heap
687        4,057,632 bytes copied during GC
688        1,065,272 bytes maximum residency (2 sample(s))
689           54,312 bytes maximum slop
690                3 MB total memory in use (0 MB lost due to fragmentation)
691
692   Generation 0:    67 collections,     0 parallel,  0.04s,  0.03s elapsed
693   Generation 1:     2 collections,     0 parallel,  0.03s,  0.04s elapsed
694
695   SPARKS: 359207 (557 converted, 149591 pruned)
696
697   INIT  time    0.00s  (  0.00s elapsed)
698   MUT   time    0.01s  (  0.02s elapsed)
699   GC    time    0.07s  (  0.07s elapsed)
700   EXIT  time    0.00s  (  0.00s elapsed)
701   Total time    0.08s  (  0.09s elapsed)
702
703   %GC time      89.5%  (75.3% elapsed)
704
705   Alloc rate    4,520,608,923 bytes per MUT second
706
707   Productivity  10.5% of total user, 9.1% of total elapsed
708 </programlisting>
709
710     <itemizedlist>
711       <listitem>
712         <para>
713         The "bytes allocated in the heap" is the total bytes allocated
714         by the program over the whole run.
715         </para>
716       </listitem>
717       <listitem>
718         <para>
719         GHC uses a copying garbage collector by default. "bytes copied
720         during GC" tells you how many bytes it had to copy during
721         garbage collection.
722         </para>
723       </listitem>
724       <listitem>
725         <para>
726         The maximum space actually used by your program is the
727         "bytes maximum residency" figure. This is only checked during
728         major garbage collections, so it is only an approximation;
729         the number of samples tells you how many times it is checked.
730         </para>
731       </listitem>
732       <listitem>
733         <para>
734         The "bytes maximum slop" tells you the most space that is ever
735         wasted due to the way GHC allocates memory in blocks.  Slop is
736         memory at the end of a block that was wasted.  There's no way
737         to control this; we just like to see how much memory is being
738         lost this way.
739         </para>
740       </listitem>
741       <listitem>
742         <para>
743         The "total memory in use" tells you the peak memory the RTS has
744         allocated from the OS.
745         </para>
746       </listitem>
747       <listitem>
748         <para>
749         Next there is information about the garbage collections done.
750         For each generation it says how many garbage collections were
751         done, how many of those collections were done in parallel,
752         the total CPU time used for garbage collecting that generation,
753         and the total wall clock time elapsed while garbage collecting
754         that generation.
755         </para>
756       </listitem>
757       <listitem>
758         <para>The <literal>SPARKS</literal> statistic refers to the
759           use of <literal>Control.Parallel.par</literal> and related
760           functionality in the program.  Each spark represents a call
761           to <literal>par</literal>; a spark is "converted" when it is
762           executed in parallel; and a spark is "pruned" when it is
763           found to be already evaluated and is discarded from the pool
764           by the garbage collector.  Any remaining sparks are
765           discarded at the end of execution, so "converted" plus
766           "pruned" does not necessarily add up to the total.</para>
767       </listitem>
768       <listitem>
769         <para>
770         Next there is the CPU time and wall clock time elapsed broken
771         down by what the runtime system was doing at the time.
772         INIT is the runtime system initialisation.
773         MUT is the mutator time, i.e. the time spent actually running
774         your code.
775         GC is the time spent doing garbage collection.
776         RP is the time spent doing retainer profiling.
777         PROF is the time spent doing other profiling.
778         EXIT is the runtime system shutdown time.
779         And finally, Total is, of course, the total.
780         </para>
781         <para>
782         %GC time tells you what percentage GC is of Total.
783         "Alloc rate" tells you the "bytes allocated in the heap" divided
784         by the MUT CPU time.
785         "Productivity" tells you what percentage of the Total CPU and wall
786         clock elapsed times are spent in the mutator (MUT).
787         </para>
788       </listitem>
789     </itemizedlist>
790
791     <para>
792         The <literal>-S</literal> flag, as well as giving the same
793         output as the <literal>-s</literal> flag, prints information
794         about each GC as it happens:
795     </para>
796
797 <programlisting>
798     Alloc    Copied     Live    GC    GC     TOT     TOT  Page Flts
799     bytes     bytes     bytes  user  elap    user    elap
800    528496     47728    141512  0.01  0.02    0.02    0.02    0    0  (Gen:  1)
801 [...]
802    524944    175944   1726384  0.00  0.00    0.08    0.11    0    0  (Gen:  0)
803 </programlisting>
804
805     <para>
806         For each garbage collection, we print:
807     </para>
808
809     <itemizedlist>
810       <listitem>
811         <para>
812           How many bytes we allocated this garbage collection.
813         </para>
814       </listitem>
815       <listitem>
816         <para>
817           How many bytes we copied this garbage collection.
818         </para>
819       </listitem>
820       <listitem>
821         <para>
822           How many bytes are currently live.
823         </para>
824       </listitem>
825       <listitem>
826         <para>
827           How long this garbage collection took (CPU time and elapsed
828           wall clock time).
829         </para>
830       </listitem>
831       <listitem>
832         <para>
833           How long the program has been running (CPU time and elapsed
834           wall clock time).
835         </para>
836       </listitem>
837       <listitem>
838         <para>
839           How many page faults occured this garbage collection.
840         </para>
841       </listitem>
842       <listitem>
843         <para>
844           How many page faults occured since the end of the last garbage
845           collection.
846         </para>
847       </listitem>
848       <listitem>
849         <para>
850           Which generation is being garbage collected.
851         </para>
852       </listitem>
853     </itemizedlist>
854
855         </listitem>
856       </varlistentry>
857     </variablelist>
858
859   </sect2>
860
861   <sect2>
862     <title>RTS options for concurrency and parallelism</title>
863
864     <para>The RTS options related to concurrency are described in
865       <xref linkend="using-concurrent" />, and those for parallelism in
866       <xref linkend="parallel-options"/>.</para>
867   </sect2>
868
869   <sect2 id="rts-profiling">
870     <title>RTS options for profiling</title>
871
872     <para>Most profiling runtime options are only available when you
873     compile your program for profiling (see
874     <xref linkend="prof-compiler-options" />, and
875     <xref linkend="rts-options-heap-prof" /> for the runtime options).
876     However, there is one profiling option that is available
877     for ordinary non-profiled executables:</para>
878
879     <variablelist>
880       <varlistentry>
881         <term>
882           <option>-hT</option>
883           <indexterm><primary><option>-hT</option></primary><secondary>RTS
884               option</secondary></indexterm>
885         </term>
886         <listitem>
887           <para>Generates a basic heap profile, in the
888             file <literal><replaceable>prog</replaceable>.hp</literal>.
889             To produce the heap profile graph,
890             use <command>hp2ps</command> (see <xref linkend="hp2ps"
891                                                     />).  The basic heap profile is broken down by data
892             constructor, with other types of closures (functions, thunks,
893             etc.) grouped into broad categories
894             (e.g. <literal>FUN</literal>, <literal>THUNK</literal>).  To
895             get a more detailed profile, use the full profiling
896             support (<xref linkend="profiling" />).</para>
897         </listitem>
898       </varlistentry>
899     </variablelist>
900   </sect2>
901
902   <sect2 id="rts-eventlog">
903     <title>Tracing</title>
904
905     <indexterm><primary>tracing</primary></indexterm>
906     <indexterm><primary>events</primary></indexterm>
907     <indexterm><primary>eventlog files</primary></indexterm>
908
909     <para>
910       When the program is linked with the <option>-eventlog</option>
911       option (<xref linkend="options-linker" />), runtime events can
912       be logged in two ways:
913     </para>
914
915     <itemizedlist>
916       <listitem>
917         <para>
918           In binary format to a file for later analysis by a
919           variety of tools.  One such tool
920           is <ulink url="http://hackage.haskell.org/package/ThreadScope">ThreadScope</ulink><indexterm><primary>ThreadScope</primary></indexterm>,
921           which interprets the event log to produce a visual parallel
922           execution profile of the program.
923         </para>
924       </listitem>
925       <listitem>
926         <para>
927           As text to standard output, for debugging purposes.
928         </para>
929       </listitem>
930     </itemizedlist>
931
932     <variablelist>
933       <varlistentry>
934         <term>
935           <option>-l<optional><replaceable>flags</replaceable></optional></option>
936           <indexterm><primary><option>-l</option></primary><secondary>RTS option</secondary></indexterm>
937         </term>
938         <listitem>
939           <para>
940             Log events in binary format to the
941             file <filename><replaceable>program</replaceable>.eventlog</filename>,
942             where <replaceable>flags</replaceable> is a sequence of
943             zero or more characters indicating which kinds of events
944             to log.  Currently there is only one type
945             supported: <literal>-ls</literal>, for scheduler events.
946           </para>
947
948           <para>
949             The format of the log file is described by the header
950             <filename>EventLogFormat.h</filename> that comes with
951             GHC, and it can be parsed in Haskell using
952             the <ulink url="http://hackage.haskell.org/package/ghc-events">ghc-events</ulink>
953             library.  To dump the contents of
954             a <literal>.eventlog</literal> file as text, use the
955             tool <literal>show-ghc-events</literal> that comes with
956             the <ulink url="http://hackage.haskell.org/package/ghc-events">ghc-events</ulink>
957             package.
958           </para>
959         </listitem>
960       </varlistentry>
961
962       <varlistentry>
963         <term>
964           <option>-v</option><optional><replaceable>flags</replaceable></optional>
965           <indexterm><primary><option>-v</option></primary><secondary>RTS option</secondary></indexterm>
966         </term>
967         <listitem>
968           <para>
969             Log events as text to standard output, instead of to
970             the <literal>.eventlog</literal> file.
971             The <replaceable>flags</replaceable> are the same as
972             for <option>-l</option>, with the additional
973             option <literal>t</literal> which indicates that the
974             each event printed should be preceded by a timestamp value
975             (in the binary <literal>.eventlog</literal> file, all
976             events are automatically associated with a timestamp).
977           </para>
978         </listitem>
979       </varlistentry>
980
981     </variablelist>
982
983     <para>
984       The debugging
985       options <option>-D<replaceable>x</replaceable></option> also
986       generate events which are logged using the tracing framework.
987       By default those events are dumped as text to stdout
988       (<option>-D<replaceable>x</replaceable></option>
989       implies <option>-v</option>), but they may instead be stored in
990       the binary eventlog file by using the <option>-l</option>
991       option.
992     </para>
993   </sect2>
994
995   <sect2 id="rts-options-debugging">
996     <title>RTS options for hackers, debuggers, and over-interested
997     souls</title>
998
999     <indexterm><primary>RTS options, hacking/debugging</primary></indexterm>
1000
1001     <para>These RTS options might be used (a)&nbsp;to avoid a GHC bug,
1002     (b)&nbsp;to see &ldquo;what's really happening&rdquo;, or
1003     (c)&nbsp;because you feel like it.  Not recommended for everyday
1004     use!</para>
1005
1006     <variablelist>
1007
1008       <varlistentry>
1009         <term>
1010           <option>-B</option>
1011           <indexterm><primary><option>-B</option></primary><secondary>RTS option</secondary></indexterm>
1012         </term>
1013         <listitem>
1014           <para>Sound the bell at the start of each (major) garbage
1015           collection.</para>
1016
1017           <para>Oddly enough, people really do use this option!  Our
1018           pal in Durham (England), Paul Callaghan, writes: &ldquo;Some
1019           people here use it for a variety of
1020           purposes&mdash;honestly!&mdash;e.g., confirmation that the
1021           code/machine is doing something, infinite loop detection,
1022           gauging cost of recently added code. Certain people can even
1023           tell what stage &lsqb;the program&rsqb; is in by the beep
1024           pattern. But the major use is for annoying others in the
1025           same office&hellip;&rdquo;</para>
1026         </listitem>
1027       </varlistentry>
1028
1029       <varlistentry>
1030         <term>
1031           <option>-D</option><replaceable>x</replaceable>
1032           <indexterm><primary>-D</primary><secondary>RTS option</secondary></indexterm>
1033         </term>
1034         <listitem>
1035           <para>
1036             An RTS debugging flag; only availble if the program was
1037             linked with the <option>-debug</option> option.  Various
1038             values of <replaceable>x</replaceable> are provided to
1039             enable debug messages and additional runtime sanity checks
1040             in different subsystems in the RTS, for
1041             example <literal>+RTS -Ds -RTS</literal> enables debug
1042             messages from the scheduler.
1043             Use <literal>+RTS&nbsp;-?</literal> to find out which
1044             debug flags are supported.
1045           </para>
1046
1047           <para>
1048             Debug messages will be sent to the binary event log file
1049             instead of stdout if the <option>-l</option> option is
1050             added.  This might be useful for reducing the overhead of
1051             debug tracing.
1052           </para>
1053         </listitem>
1054       </varlistentry>
1055
1056       <varlistentry>
1057         <term>
1058           <option>-r</option><replaceable>file</replaceable>
1059           <indexterm><primary><option>-r</option></primary><secondary>RTS option</secondary></indexterm>
1060           <indexterm><primary>ticky ticky profiling</primary></indexterm>
1061           <indexterm><primary>profiling</primary><secondary>ticky ticky</secondary></indexterm>
1062         </term>
1063         <listitem>
1064           <para>Produce &ldquo;ticky-ticky&rdquo; statistics at the
1065           end of the program run (only available if the program was
1066           linked with <option>-debug</option>).
1067           The <replaceable>file</replaceable> business works just like
1068           on the <option>-S</option> RTS option, above.</para>
1069
1070           <para>For more information on ticky-ticky profiling, see
1071           <xref linkend="ticky-ticky"/>.</para>
1072         </listitem>
1073       </varlistentry>
1074
1075       <varlistentry>
1076         <term>
1077           <option>-xc</option>
1078           <indexterm><primary><option>-xc</option></primary><secondary>RTS option</secondary></indexterm>
1079         </term>
1080         <listitem>
1081           <para>(Only available when the program is compiled for
1082           profiling.)  When an exception is raised in the program,
1083           this option causes the current cost-centre-stack to be
1084           dumped to <literal>stderr</literal>.</para>
1085
1086           <para>This can be particularly useful for debugging: if your
1087           program is complaining about a <literal>head []</literal>
1088           error and you haven't got a clue which bit of code is
1089           causing it, compiling with <literal>-prof
1090           -auto-all</literal> and running with <literal>+RTS -xc
1091           -RTS</literal> will tell you exactly the call stack at the
1092           point the error was raised.</para>
1093
1094           <para>The output contains one line for each exception raised
1095           in the program (the program might raise and catch several
1096           exceptions during its execution), where each line is of the
1097           form:</para>
1098
1099 <screen>
1100 &lt; cc<subscript>1</subscript>, ..., cc<subscript>n</subscript> &gt;
1101 </screen>
1102           <para>each <literal>cc</literal><subscript>i</subscript> is
1103           a cost centre in the program (see <xref
1104           linkend="cost-centres"/>), and the sequence represents the
1105           &ldquo;call stack&rdquo; at the point the exception was
1106           raised.  The leftmost item is the innermost function in the
1107           call stack, and the rightmost item is the outermost
1108           function.</para>
1109
1110         </listitem>
1111       </varlistentry>
1112
1113       <varlistentry>
1114         <term>
1115           <option>-Z</option>
1116           <indexterm><primary><option>-Z</option></primary><secondary>RTS option</secondary></indexterm>
1117         </term>
1118         <listitem>
1119           <para>Turn <emphasis>off</emphasis> &ldquo;update-frame
1120           squeezing&rdquo; at garbage-collection time.  (There's no
1121           particularly good reason to turn it off, except to ensure
1122           the accuracy of certain data collected regarding thunk entry
1123           counts.)</para>
1124         </listitem>
1125       </varlistentry>
1126     </variablelist>
1127
1128   </sect2>
1129
1130   <sect2>
1131     <title>Linker flags to change RTS behaviour</title>
1132
1133     <indexterm><primary>RTS behaviour, changing</primary></indexterm>
1134
1135     <para>
1136       GHC lets you exercise rudimentary control over the RTS settings
1137       for any given program, by using the <literal>-with-rtsopts</literal>
1138       linker flag. For example, to set <literal>-H128m -K1m</literal>,
1139       link with <literal>-with-rtsopts="-H128m -K1m"</literal>.
1140     </para>
1141
1142   </sect2>
1143
1144   <sect2 id="rts-hooks">
1145     <title>&ldquo;Hooks&rdquo; to change RTS behaviour</title>
1146
1147     <indexterm><primary>hooks</primary><secondary>RTS</secondary></indexterm>
1148     <indexterm><primary>RTS hooks</primary></indexterm>
1149     <indexterm><primary>RTS behaviour, changing</primary></indexterm>
1150
1151     <para>GHC lets you exercise rudimentary control over the RTS
1152     settings for any given program, by compiling in a
1153     &ldquo;hook&rdquo; that is called by the run-time system.  The RTS
1154     contains stub definitions for all these hooks, but by writing your
1155     own version and linking it on the GHC command line, you can
1156     override the defaults.</para>
1157
1158     <para>Owing to the vagaries of DLL linking, these hooks don't work
1159     under Windows when the program is built dynamically.</para>
1160
1161     <para>The hook <literal>ghc_rts_opts</literal><indexterm><primary><literal>ghc_rts_opts</literal></primary>
1162       </indexterm>lets you set RTS
1163     options permanently for a given program.  A common use for this is
1164     to give your program a default heap and/or stack size that is
1165     greater than the default.  For example, to set <literal>-H128m
1166     -K1m</literal>, place the following definition in a C source
1167     file:</para>
1168
1169 <programlisting>
1170 char *ghc_rts_opts = "-H128m -K1m";
1171 </programlisting>
1172
1173     <para>Compile the C file, and include the object file on the
1174     command line when you link your Haskell program.</para>
1175
1176     <para>These flags are interpreted first, before any RTS flags from
1177     the <literal>GHCRTS</literal> environment variable and any flags
1178     on the command line.</para>
1179
1180     <para>You can also change the messages printed when the runtime
1181     system &ldquo;blows up,&rdquo; e.g., on stack overflow.  The hooks
1182     for these are as follows:</para>
1183
1184     <variablelist>
1185
1186       <varlistentry>
1187         <term>
1188           <function>void OutOfHeapHook (unsigned long, unsigned long)</function>
1189           <indexterm><primary><function>OutOfHeapHook</function></primary></indexterm>
1190         </term>
1191         <listitem>
1192           <para>The heap-overflow message.</para>
1193         </listitem>
1194       </varlistentry>
1195
1196       <varlistentry>
1197         <term>
1198           <function>void StackOverflowHook (long int)</function>
1199           <indexterm><primary><function>StackOverflowHook</function></primary></indexterm>
1200         </term>
1201         <listitem>
1202           <para>The stack-overflow message.</para>
1203         </listitem>
1204       </varlistentry>
1205
1206       <varlistentry>
1207         <term>
1208           <function>void MallocFailHook (long int)</function>
1209           <indexterm><primary><function>MallocFailHook</function></primary></indexterm>
1210         </term>
1211         <listitem>
1212           <para>The message printed if <function>malloc</function>
1213           fails.</para>
1214         </listitem>
1215       </varlistentry>
1216     </variablelist>
1217
1218     <para>For examples of the use of these hooks, see GHC's own
1219     versions in the file
1220     <filename>ghc/compiler/parser/hschooks.c</filename> in a GHC
1221     source tree.</para>
1222   </sect2>
1223
1224   <sect2>
1225     <title>Getting information about the RTS</title>
1226
1227     <indexterm><primary>RTS</primary></indexterm>
1228
1229     <para>It is possible to ask the RTS to give some information about
1230     itself. To do this, use the <option>--info</option> flag, e.g.</para>
1231 <screen>
1232 $ ./a.out +RTS --info
1233  [("GHC RTS", "YES")
1234  ,("GHC version", "6.7")
1235  ,("RTS way", "rts_p")
1236  ,("Host platform", "x86_64-unknown-linux")
1237  ,("Host architecture", "x86_64")
1238  ,("Host OS", "linux")
1239  ,("Host vendor", "unknown")
1240  ,("Build platform", "x86_64-unknown-linux")
1241  ,("Build architecture", "x86_64")
1242  ,("Build OS", "linux")
1243  ,("Build vendor", "unknown")
1244  ,("Target platform", "x86_64-unknown-linux")
1245  ,("Target architecture", "x86_64")
1246  ,("Target OS", "linux")
1247  ,("Target vendor", "unknown")
1248  ,("Word size", "64")
1249  ,("Compiler unregisterised", "NO")
1250  ,("Tables next to code", "YES")
1251  ]
1252 </screen>
1253     <para>The information is formatted such that it can be read as a
1254     of type <literal>[(String, String)]</literal>. Currently the following
1255     fields are present:</para>
1256
1257     <variablelist>
1258
1259       <varlistentry>
1260         <term><literal>GHC RTS</literal></term>
1261         <listitem>
1262           <para>Is this program linked against the GHC RTS? (always
1263           "YES").</para>
1264         </listitem>
1265       </varlistentry>
1266
1267       <varlistentry>
1268         <term><literal>GHC version</literal></term>
1269         <listitem>
1270           <para>The version of GHC used to compile this program.</para>
1271         </listitem>
1272       </varlistentry>
1273
1274       <varlistentry>
1275         <term><literal>RTS way</literal></term>
1276         <listitem>
1277           <para>The variant (&ldquo;way&rdquo;) of the runtime. The
1278           most common values are <literal>rts</literal> (vanilla),
1279           <literal>rts_thr</literal> (threaded runtime, i.e. linked using the
1280           <literal>-threaded</literal> option) and <literal>rts_p</literal>
1281           (profiling runtime, i.e. linked using the <literal>-prof</literal>
1282           option). Other variants include <literal>debug</literal>
1283           (linked using <literal>-debug</literal>),
1284           <literal>t</literal> (ticky-ticky profiling) and
1285           <literal>dyn</literal> (the RTS is
1286           linked in dynamically, i.e. a shared library, rather than statically
1287           linked into the executable itself). These can be combined,
1288           e.g. you might have <literal>rts_thr_debug_p</literal>.</para>
1289         </listitem>
1290       </varlistentry>
1291
1292       <varlistentry>
1293         <term>
1294             <literal>Target platform</literal>,
1295             <literal>Target architecture</literal>,
1296             <literal>Target OS</literal>,
1297             <literal>Target vendor</literal>
1298         </term>
1299         <listitem>
1300           <para>These are the platform the program is compiled to run on.</para>
1301         </listitem>
1302       </varlistentry>
1303
1304       <varlistentry>
1305         <term>
1306             <literal>Build platform</literal>,
1307             <literal>Build architecture</literal>,
1308             <literal>Build OS</literal>,
1309             <literal>Build vendor</literal>
1310         </term>
1311         <listitem>
1312           <para>These are the platform where the program was built
1313           on. (That is, the target platform of GHC itself.) Ordinarily
1314           this is identical to the target platform. (It could potentially
1315           be different if cross-compiling.)</para>
1316         </listitem>
1317       </varlistentry>
1318
1319       <varlistentry>
1320         <term>
1321             <literal>Host platform</literal>,
1322             <literal>Host architecture</literal>
1323             <literal>Host OS</literal>
1324             <literal>Host vendor</literal>
1325         </term>
1326         <listitem>
1327           <para>These are the platform where GHC itself was compiled.
1328           Again, this would normally be identical to the build and
1329           target platforms.</para>
1330         </listitem>
1331       </varlistentry>
1332
1333       <varlistentry>
1334         <term><literal>Word size</literal></term>
1335         <listitem>
1336           <para>Either <literal>"32"</literal> or <literal>"64"</literal>,
1337           reflecting the word size of the target platform.</para>
1338         </listitem>
1339       </varlistentry>
1340
1341       <varlistentry>
1342         <term><literal>Compiler unregistered</literal></term>
1343         <listitem>
1344           <para>Was this program compiled with an &ldquo;unregistered&rdquo;
1345           version of GHC? (I.e., a version of GHC that has no platform-specific
1346           optimisations compiled in, usually because this is a currently
1347           unsupported platform.) This value will usually be no, unless you're
1348           using an experimental build of GHC.</para>
1349         </listitem>
1350       </varlistentry>
1351
1352       <varlistentry>
1353         <term><literal>Tables next to code</literal></term>
1354         <listitem>
1355           <para>Putting info tables directly next to entry code is a useful
1356           performance optimisation that is not available on all platforms.
1357           This field tells you whether the program has been compiled with
1358           this optimisation. (Usually yes, except on unusual platforms.)</para>
1359         </listitem>
1360       </varlistentry>
1361
1362     </variablelist>
1363
1364   </sect2>
1365 </sect1>
1366
1367 <!-- Emacs stuff:
1368      ;;; Local Variables: ***
1369      ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter" "sect1") ***
1370      ;;; End: ***
1371  -->