Opened 9 years ago

Closed 9 years ago

#4838 closed bug (fixed)

LLVM mangler takes too long at runtime

Reported by: benl Owned by: dterei
Priority: normal Milestone: 7.4.1
Component: Compiler (LLVM) Version: 7.0.1
Keywords: Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Compiling the BarnesHut example from DPH takes 30 min with -fllvm, but only 2 min with -fasm. The Words benchmark has similar problems. Running GHC with -v and using 'top' shows that the llvm compiler finishes in < 1min, so the problem is in GHC and not LLVM. Suspect complexity issues in LLVM mangler, which is only needed on OSX. #4211 is related.

limitingfactor:dph-examples benl$ pwd
/Users/benl/devel/ghc/build/nightly/ghc-head/libraries/dph/dph-examples

# Compiling with the NCG
/usr/bin/time ../../../inplace/bin/ghc-stage2 -fasm -Odph \
 --make imaginary/Words/Main.hs -package dph-prim-par -package dph-par \
 -iimaginary/Words -fforce-recomp
[1 of 2] Compiling WordsVect        ( imaginary/Words/WordsVect.hs, imaginary/Words/WordsVect.o )
[2 of 2] Compiling Main             ( imaginary/Words/Main.hs, imaginary/Words/Main.o )
Linking imaginary/Words/Main ...
       93.21 real        91.30 user         1.68 sys

# Compiling with LLVM
/usr/bin/time ../../../inplace/bin/ghc-stage2 -fllvm -Odph \
 --make imaginary/Words/Main.hs -package dph-prim-par \
 -package dph-par -iimaginary/Words -fforce-recomp
[1 of 2] Compiling WordsVect        ( imaginary/Words/WordsVect.hs, imaginary/Words/WordsVect.o )

# ... 10 mins later I'm getting bored so Control-C it, though it's completed in the past.
^C      677.91 real       673.53 user         3.59 sys

Change History (5)

comment:1 Changed 9 years ago by igloo

Milestone: 7.2.1

comment:2 Changed 9 years ago by dterei

Owner: changed from davidterei@… to dterei

comment:3 Changed 9 years ago by dterei

Yeah there were some pretty bad design issues with the Mangler. I've just had an initial crack at a revision.

Current Mangler:

time ./Driver WordsVect.s
./Driver WordsVect.s  4899.54s user 3.72s system 99% cpu 1:21:47.95 total

New Mangler:

time ./Driver WordsVect.s
./Driver WordsVect.s  117.79s user 0.38s system 93% cpu 2:06.15 total

So much better already. I still want to try a few different designs before I submit a patch though. Progress at long last :)

comment:4 Changed 9 years ago by dterei

Status: newmerge

Fixed! Thanks for the bug report, old code was embarrassingly bad.

The dph example you used now compiles in a little under 3 minutes. The mangler now only takes about 2 seconds to do its job in this case so extra time is all due to llvm.

comment:5 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed

Merged:

Sun Feb 13 01:44:06 GMT 2011  David Terei <davidterei@gmail.com>
  * LLVM: Huge improvement to mangler speed.
  Ignore-this: 4eeaa572dfe956c990895154bd942bb2
  
  The old llvm mangler was horrible! Very slow
  due to bad design and code. New version is
  linear complexity as it should be and far
  lower coefficients. This fixes trac 4838.
Note: See TracTickets for help on using tickets.