Ticket #3840 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

ghc-6.12.1 takes longer to compile code and produces bigger binaries compared to ghc-6.10.4

Reported by: maeder Owned by: igloo
Priority: high Milestone: 7.0.1
Component: Compiler Version: 6.12.3
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Compiling 348 files from our hets project (using "cabal build")

using ghc-6.12.1 (from http://www.haskell.org/ghc/dist/6.12.1/ghc-6.12.1-i386-unknown-linux-n.tar.bz2) takes 291.55s and produces a binary with 21540628 Bytes (after strip)

using ghc-6.10.4 (from http://www.haskell.org/ghc/dist/6.10.4/ghc-6.10.4-i386-unknown-linux-n.tar.bz2) takes 216.28s and produces a binary with 14548284 Bytes (after strip)

Furthermore the stripped ghc (and haddock) binaries from the distributions differ already:

ghc-6.12.1 17MB ghc-6.10.4 14MB

(The ghc-6.12.1 distribution misses the install-strip target)

Attachments

log.ghc-6.10.4 Download (41.2 KB) - added by maeder 3 years ago.
log.ghc-6.12.1 Download (41.4 KB) - added by maeder 3 years ago.
Hets.tgz Download (25.2 KB) - added by maeder 3 years ago.
smaller example

Change History

Changed 3 years ago by maeder

Changed 3 years ago by maeder

  Changed 3 years ago by maeder

looking at the object files this looks similar to #955

ghc-6.10.4

684K dist/build/hets/hets-tmp/HasCASL/ATC_HasCASL.o
624K dist/build/hets/hets-tmp/ATC/Sml_cats.o
552K dist/build/hets/hets-tmp/CASL/ATC_CASL.o
540K dist/build/hets/hets-tmp/SoftFOL/Sign.o
520K dist/build/hets/hets-tmp/OMDoc/OMDocInterface.o
504K dist/build/hets/hets-tmp/Static/DevGraph.o

ghc-6.12.1

 2,8M dist/build/hets/hets-tmp/HasCASL/ATC_HasCASL.o
 2,2M dist/build/hets/hets-tmp/CASL/ATC_CASL.o
 1,6M dist/build/hets/hets-tmp/OWL/ReadWrite.o
 1,5M dist/build/hets/hets-tmp/CspCASL/ATC_CspCASL.o
 1,2M dist/build/hets/hets-tmp/OMDoc/ATC_OMDoc.o
 1,1M dist/build/hets/hets-tmp/Isabelle/ATC_Isabelle.o
 1,1M dist/build/hets/hets-tmp/SoftFOL/ATC_SoftFOL.o

That is, instances are expanded too much.

  Changed 3 years ago by maeder

Changing the generated instances to one-liners plus auxiliary function (as helped for #955) does not help much now:

ghc-6.12.1 with one-liner instances

 2,2M dist/build/hets/hets-tmp/CASL/ATC_CASL.o
 2,1M dist/build/hets/hets-tmp/HasCASL/ATC_HasCASL.o
 1,6M dist/build/hets/hets-tmp/OWL/ReadWrite.o
 1,2M dist/build/hets/hets-tmp/CspCASL/ATC_CspCASL.o
 1,1M dist/build/hets/hets-tmp/OMDoc/ATC_OMDoc.o
 1,1M dist/build/hets/hets-tmp/SoftFOL/ATC_SoftFOL.o

follow-up: ↓ 8   Changed 3 years ago by simonpj

Sorry about this. It's jolly annoying. I don't know what's going on here, and unfortunately it's difficult to reproduce because only you have the code, and it doubtless depends on a zillion other libraries.

Is it possible to try with HEAD? It has the new inlining story, which has changed (yet again) the way in which instances are treated. If it's different it'd be helpful to know.

Maybe try with -dshow-passes (both with 6.10 and 6.12) which should show in which pass the blow up happens.

You take one of the offending modules, and cut it down so that there is (say) just one instance declaration that demonstrates the blow up?

follow-up: ↓ 5   Changed 3 years ago by maeder

Maybe you (or someone else) could check if (or why) the ghc binary itself is much bigger when compiled with ghc-6.12.1 versus ghc-6.10.4. Or why the new binary distribution is so much bigger?

in reply to: ↑ 4 ; follow-up: ↓ 6   Changed 3 years ago by simonmar

Replying to maeder:

Maybe you (or someone else) could check if (or why) the ghc binary itself is much bigger when compiled with ghc-6.12.1 versus ghc-6.10.4. Or why the new binary distribution is so much bigger?

One reason the GHC binary is bigger is that it now has all the native code generators compiled in, whereas in 6.10 it only had one. Doubtless the compiler has just got bigger between 6.10 and 6.12 too.

The distribution is bigger because it now contains shared libraries.

in reply to: ↑ 5   Changed 3 years ago by simonmar

Replying to simonmar:

One reason the GHC binary is bigger is that it now has all the native code generators compiled in, whereas in 6.10 it only had one. Doubtless the compiler has just got bigger between 6.10 and 6.12 too. The distribution is bigger because it now contains shared libraries.

I should add that we did measure binary sizes for nofib before releasing 6.12.1, and we found that while the size of binaries typically increased by around 10\%, the size of individually compiled modules wasn't much different, which means that the increase is generally due to more code, rather than unnecessary inlining for example.

Another thing that we added is the new IO library: Unicode support makes the base package bigger.

  Changed 3 years ago by maeder

Interestingly, if I compile the two big files directly, they stay small. It seems that compiling unrelated modules before increases .o files.

> ghc --make -DTIME_WITH_TYPEABLE HasCASL/ATC_HasCASL.hs
[ 1 of 34] Compiling Common.InjMap    ( Common/InjMap.hs, Common/InjMap.o )  
...
[34 of 34] Compiling HasCASL.ATC_HasCASL ( HasCASL/ATC_HasCASL.hs, HasCASL/ATC_HasCASL.o )
> ls -sh HasCASL/ATC_HasCASL.o
732K HasCASL/ATC_HasCASL.o
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.1

in reply to: ↑ 3   Changed 3 years ago by maeder

Replying to simonpj:

Is it possible to try with HEAD? It has the new inlining story, which has changed (yet again) the way in which instances are treated. If it's different it'd be helpful to know.

I've looked under http://www.haskell.org/ghc/dist/current/dist/ The linux-distros do not work for me (missing libtinfo). The newest src-bundle is from 20100108.

  Changed 3 years ago by maeder

I should mention that all instances in our ATC-files are "orphan".

  Changed 3 years ago by maeder

I've tried with ghc-6.13.20100211 and the results are much better though not as good as for ghc-6.10.4

1,3M dist/build/hets/hets-tmp/HasCASL/ATC_HasCASL.o
872K dist/build/hets/hets-tmp/CASL/ATC_CASL.o
600K dist/build/hets/hets-tmp/SoftFOL/ATC_SoftFOL.o
592K dist/build/hets/hets-tmp/ATC/Sml_cats.o
560K dist/build/hets/hets-tmp/Maude/ATC_Maude.o
552K dist/build/hets/hets-tmp/OWL/AS.o
548K dist/build/hets/hets-tmp/SoftFOL/Sign.o
544K dist/build/hets/hets-tmp/Maude/AS_Maude.o
540K dist/build/hets/hets-tmp/Static/DevGraph.o
500K dist/build/hets/hets-tmp/HasCASL/As.o
468K dist/build/hets/hets-tmp/ATC/DevGraph.o

  Changed 3 years ago by igloo

  • milestone set to 6.12.2

Changed 3 years ago by maeder

smaller example

  Changed 3 years ago by maeder

I've attached a small subset of our sources that hopefully illustrate the problem.

tar zxvf Hets.tgz
cd Hets
ghc --make -O -iatermlib/src Common/atc.hs

ls -S1sh */*.o */*/*.o */*/*/*.o
rm */*.o */*/*.o */*/*/*.o

The only packages required to compile are base, containers, array, old-time, time and ghc-prim. It'll compile 15 files. The generated instances are in the file ATC/AS_Annotation.hs. The size of the file ATC/AS_Annotation.o is:

ghc-6.10.4: 116K
ghc-6.12.1: 528K
ghc-6.13.20100211: 196K

  Changed 3 years ago by igloo

  • milestone changed from 6.12.2 to 6.12.3

  Changed 3 years ago by maeder

  • version changed from 6.12.1 to 6.12.3

Unfortunately the problem is not fixed for ghc-6.12.3 (and ghc-6.12.2). The size of the file ATC/AS_Annotation.o is:

ghc-6.12.3: 500K

  Changed 3 years ago by igloo

  • milestone changed from 6.12.3 to 6.14.1

  Changed 3 years ago by simonpj

  • owner set to igloo
  • priority changed from normal to high

Christian: is there any chance you could try with HEAD? That's what will constitute GHC 7.0, to be released shortly. Inlining is completely re-implemented, so things may be very different.

Also Ian: might it be worth trying with the download he gives? Thanks.

Simon

  Changed 3 years ago by maeder

I've checked my attachment Hets.tgz with ghc-6.13.20100915 and the size of the critical file ATC/AS_Annotation.o 172K looks alright:

216K atermlib/src/ATerm/Conversion.o
208K Common/AS_Annotation.o
172K ATC/AS_Annotation.o
100K atermlib/src/ATerm/AbstractSyntax.o
100K Common/Id.o
...

  Changed 3 years ago by simonpj

  • status changed from new to closed
  • resolution set to fixed

OK good. I'll mark it as fixed. Yell if it goes bad again!

Simon

Note: See TracTickets for help on using tickets.