incremental linking?

Andre Pang ozone@algorithm.com.au
Thu, 28 Nov 2002 15:36:32 -0800


On Wed, Nov 27, 2002 at 03:55:54PM -0000, Simon Marlow wrote:

> Those who experience long link times (longer than a few seconds), please
> reply with your
> 
>   - platform / OS version
>   - versions of relevent things (GHC, GCC, binutils).
>   - time to link 'main = print "hello"'.

Platform: Debian unstable, with the Debian GHC package
(maintained by Michael Weber, iirc)

GHC version: 5.04

GCC version: 2.95.4

binutils: GNU ld version 2.13.90.0.10 20021010 Debian GNU/Linux

For the runtime loader example, this is the thing which takes
ages to link:

    ghc -package lang -optl-export-dynamic -fglasgow-exts -O2 -o TextFilter  Main.o TextFilter.o TextFilterPluginAPI.o -ldl -lHSrts -lHSlang /usr/lib/ghc-5.04/HSbase.o /usr/lib/ghc-5.04/HSlang.o ../runtime_loader/libRuntimeLoader.a
    make  169.92s user 0.86s system 98% cpu 2:52.81 total

Linking in a 'main = print "hello"' is normal:

    15:13 exodus:~/bar % ghc Main.hs 
    ghc Main.hs  3.44s user 0.23s system 78% cpu 4.677 total

Here's the fun part:

    15:18 exodus:~/bar % time ghc -package lang /usr/lib/ghc-5.04/HSbase.o /usr/lib/ghc-5.04/HSlang.o Main.hs
    ghc -package lang /usr/lib/ghc-5.04/HSbase.o /usr/lib/ghc-5.04/HSlang.o   1.42s user 0.34s system 105% cpu 1.666 total

    15:30 exodus:~/bar % time ghc -optl-export-dynamic -package lang Main.hs
    ghc -optl-export-dynamic -package lang Main.hs  3.68s user 0.21s system 102% cpu 3.793 total

    15:22 exodus:~/bar % time ghc -optl-export-dynamic -package lang /usr/lib/ghc-5.04/HSbase.o /usr/lib/ghc-5.04/HSlang.o Main.hs
    ghc -optl-export-dynamic -package lang /usr/lib/ghc-5.04/HSbase.o Main.hs  169.05s user 0.87s system 100% cpu 2:49.85 total

I guess it looks like -optl-export-dynamic in conjunction with
linking in the .o's is the killer.

strace seems to indicate that ld isn't doing any syscalls when
it's doing the -export-dynamic work; it just mmaps a huge wad of
memory before starting, then it doesn't make a single syscall
until it goes to write the final output.  Presumably it's mmapping
the .o's into memory to do the -export-dynamic magic.

> Does starting up GHCi take a long time?

GHCI startup appears to be normal (a few seconds).

At least for me the culprit is -optl-export-dynamic ... I'm not
sure that this is in GHC's problem domain any more.


-- 
#ozone/algorithm <ozone@algorithm.com.au>          - trust.in.love.to.save