default), and you have lots of memory, try increasing the
maximum with the
<option>-M<size></option><indexterm><primary>-M<size>
default), and you have lots of memory, try increasing the
maximum with the
<option>-M<size></option><indexterm><primary>-M<size>
- option</primary></indexterm> option, e.g.: <Command>ghc -c
- -O -M1024m Foo.hs</Command>.</para>
+ option</primary></indexterm> option, e.g.: <command>ghc -c
+ -O -M1024m Foo.hs</command>.</para>
<para>Increasing the default allocation area size used by
the compiler's RTS might also help: use the
<para>Increasing the default allocation area size used by
the compiler's RTS might also help: use the
<listitem>
<para>As soon as GHC plus its “fellow citizens”
(other processes on your machine) start using more than the
<listitem>
<para>As soon as GHC plus its “fellow citizens”
(other processes on your machine) start using more than the
- <Emphasis>real memory</Emphasis> on your machine, and the
- machine starts “thrashing,” <Emphasis>the party
- is over</Emphasis>. Compile times will be worse than
+ <emphasis>real memory</emphasis> on your machine, and the
+ machine starts “thrashing,” <emphasis>the party
+ is over</emphasis>. Compile times will be worse than
page faults you're getting.</para>
<para>If you don't know what virtual memory, thrashing, and
page faults are, or you don't know the memory configuration
page faults you're getting.</para>
<para>If you don't know what virtual memory, thrashing, and
page faults are, or you don't know the memory configuration
about memory use: you'll just make your life a misery (and
for other people, too, probably).</para>
</listitem>
about memory use: you'll just make your life a misery (and
for other people, too, probably).</para>
</listitem>
- <Emphasis>compile</Emphasis> on a fast machine using
- remotely-mounted disks; then <Emphasis>link</Emphasis> on a
+ <emphasis>compile</emphasis> on a fast machine using
+ remotely-mounted disks; then <emphasis>link</emphasis> on a
<literal>import Foo (...stuff I want...)</literal> You can
get GHC to tell you the minimal set of required imports by
using the <option>-ddump-minimal-imports</option> option
<literal>import Foo (...stuff I want...)</literal> You can
get GHC to tell you the minimal set of required imports by
using the <option>-ddump-minimal-imports</option> option
<para>Truthfully, the reduction on compilation time will be
very small. However, judicious use of
<para>Truthfully, the reduction on compilation time will be
very small. However, judicious use of
<para>The key tool to use in making your Haskell program run
faster are GHC's profiling facilities, described separately in
<para>The key tool to use in making your Haskell program run
faster are GHC's profiling facilities, described separately in
- <XRef LinkEnd="profiling">. There is <Emphasis>no
- substitute</Emphasis> for finding where your program's time/space
- is <Emphasis>really</Emphasis> going, as opposed to where you
+ <xref linkend="profiling"/>. There is <emphasis>no
+ substitute</emphasis> for finding where your program's time/space
+ is <emphasis>really</emphasis> going, as opposed to where you
is to use better algorithms. Once profiling has thrown the
spotlight on the guilty time-consumer(s), it may be better to
re-think your program than to try all the tweaks listed below.</para>
<para>Another extremely efficient way to make your program snappy
is to use library code that has been Seriously Tuned By Someone
is to use better algorithms. Once profiling has thrown the
spotlight on the guilty time-consumer(s), it may be better to
re-think your program than to try all the tweaks listed below.</para>
<para>Another extremely efficient way to make your program snappy
is to use library code that has been Seriously Tuned By Someone
quicksort than the one in <literal>Data.List</literal>, but it
will take you much longer than typing <literal>import
Data.List</literal>.</para>
quicksort than the one in <literal>Data.List</literal>, but it
will take you much longer than typing <literal>import
Data.List</literal>.</para>
<indexterm><primary>overloading, death to</primary></indexterm>
<para>Specialize the overloading on key functions in
<indexterm><primary>overloading, death to</primary></indexterm>
<para>Specialize the overloading on key functions in
- your program. See <XRef LinkEnd="specialize-pragma">
- and <XRef LinkEnd="specialize-instance-pragma">.</para>
+ your program. See <xref linkend="specialize-pragma"/>
+ and <xref linkend="specialize-instance-pragma"/>.</para>
files for overloaded type signatures. You can view
interface files using the
<option>--show-iface</option> option (see <xref
files for overloaded type signatures. You can view
interface files using the
<option>--show-iface</option> option (see <xref
the third field in the pragma; it should say
<literal>__S <string></literal>. The
<literal><string></literal> gives the strictness of
the third field in the pragma; it should say
<literal>__S <string></literal>. The
<literal><string></literal> gives the strictness of
- the function's arguments. <Function>L</Function> is lazy
- (bad), <Function>S</Function> and <Function>E</Function> are
- strict (good), <Function>P</Function> is
- “primitive” (good), <Function>U(...)</Function>
+ the function's arguments. <function>L</function> is lazy
+ (bad), <function>S</function> and <function>E</function> are
+ strict (good), <function>P</function> is
+ “primitive” (good), <function>U(...)</function>
means “the first component of the pair isn't used; the
second component is itself unpackable, with three components
(lazy in the first, strict in the second \&
means “the first component of the pair isn't used; the
second component is itself unpackable, with three components
(lazy in the first, strict in the second \&
<listitem>
<para>Placing <literal>INLINE</literal> pragmas on certain
functions that are used a lot can have a dramatic effect.
<listitem>
<para>Placing <literal>INLINE</literal> pragmas on certain
functions that are used a lot can have a dramatic effect.
module, GHC must assume that everything in that module will
be exported. This has various pessimising effects. For
example, if a bit of code is actually
module, GHC must assume that everything in that module will
be exported. This has various pessimising effects. For
example, if a bit of code is actually
effects), GHC will not be able to throw it away, because it
is exported and some other module may be relying on its
existence.</para>
effects), GHC will not be able to throw it away, because it
is exported and some other module may be relying on its
existence.</para>
<para>It can also help in a third way: when used with
<option>-funbox-strict-fields</option> (see <xref
<para>It can also help in a third way: when used with
<option>-funbox-strict-fields</option> (see <xref
unboxed in the constructor, and one or more levels of
indirection may be removed. Unpacking only happens for
single-constructor datatypes (<literal>Int</literal> is a
unboxed in the constructor, and one or more levels of
indirection may be removed. Unpacking only happens for
single-constructor datatypes (<literal>Int</literal> is a
some information about using unboxed types.</para>
<para>Before resorting to explicit unboxed types, try using
some information about using unboxed types.</para>
<para>Before resorting to explicit unboxed types, try using
of massively-tuned library code, and the best thing is not
to compete with it, but link with it.</para>
of massively-tuned library code, and the best thing is not
to compete with it, but link with it.</para>
a giant array of <literal>Float</literal>s. They take up
half the space in the heap compared to
<literal>Doubles</literal>. However, this isn't true on a
a giant array of <literal>Float</literal>s. They take up
half the space in the heap compared to
<literal>Doubles</literal>. However, this isn't true on a
<option>-M<size></option><indexterm><primary>-M<size>
RTS option</primary></indexterm> or
<option>-A<size></option><indexterm><primary>-A<size>
<option>-M<size></option><indexterm><primary>-M<size>
RTS option</primary></indexterm> or
<option>-A<size></option><indexterm><primary>-A<size>
<para>This is especially important if your program uses a
lot of mutable arrays of pointers or mutable variables
<para>This is especially important if your program uses a
lot of mutable arrays of pointers or mutable variables
option</primary></indexterm> option for the extreme case. (“Only unfoldings with
zero cost should proceed.”) Warning: except in certain specialised
cases (like Happy parsers) this is likely to actually
option</primary></indexterm> option for the extreme case. (“Only unfoldings with
zero cost should proceed.”) Warning: except in certain specialised
cases (like Happy parsers) this is likely to actually
with <option>+RTS -Sstderr</option>, and remove all doubt! (You'll
see the heap usage get bigger and bigger…)
[Hmmm…this might be even easier with the
with <option>+RTS -Sstderr</option>, and remove all doubt! (You'll
see the heap usage get bigger and bigger…)
[Hmmm…this might be even easier with the
<indexterm><primary>-G RTS option</primary></indexterm>
<indexterm><primary>-Sstderr RTS option</primary></indexterm>
</para>
<para>
<indexterm><primary>-G RTS option</primary></indexterm>
<indexterm><primary>-Sstderr RTS option</primary></indexterm>
</para>
<para>