Compiling faster

George Russell ger at
Thu Sep 23 07:41:51 EDT 2004

I am responsible for a large project containing 577 Haskell library
modules, with almost 120 KLOC.  These modules are divided into packages.
They can be compiled either
(1) the old way, using ghc -M to generate dependency files, and then
using make to call GHC once for each file.
(2) the new way, compiling each package in one GHC invocation using

There is a big difference in speed between the two.  The new way takes
4 minutes 16 seconds; the old way 6 minutes 55 seconds, both measured in
wallclock time.  (This is, admittedly, with -Onot.)  My guess is that a
lot of this is due to initialisation, particularly the need to read and
parse lots of .hi files.  This takes a lot of time, even though in fact
all the .hi files during this test were on local disks.

I think therefore the section "Sooner: producing a program more quickly"

should recommend using --make to compile lots of files at a time.
And by the way, that might not be a bad idea for GHC itself ...

More information about the Glasgow-haskell-users mailing list