Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#2438 closed bug (fixed)

memory performance problem when compiling lots of derived instances in a single file

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

Description

I'm playing with deriving Data/Typeable for the GHC AST types (you'll need a recent HEAD for the standalone deriving fixes #2378, and I've got to use the generics-internal CPP tricks to work around #2433).

After getting the first compiler-complaint-free version of the instances source, self-same compiler went away and tried to get all the memory it could find (I had to kill the process). After splitting the source into two, one importing the other, there is no problem loading them anymore.

  • Instances.hs imports Instances0.hs: loading Instances into GHCi, version 6.9.20080709 works fine.
  • All.hs merges the source of Instances and Instances0 into a single module: trying to load All into GHCi, version 6.9.20080709 consumes memory like crazy.

Compiling All.hs shouldn't behave like this in the first place, but if just splitting the file into two helps, the compiler should be able to do the split implicitly (sparing me the manual dependency analysis).

Attachments (3)

All.hs (9.5 KB) - added by claus 9 years ago.
merged source
Instances0.hs (4.5 KB) - added by claus 9 years ago.
split source, imported part
Instances.hs (5.5 KB) - added by claus 9 years ago.
split source, importing part

Download all attachments as: .zip

Change History (8)

Changed 9 years ago by claus

Attachment: All.hs added

merged source

Changed 9 years ago by claus

Attachment: Instances0.hs added

split source, imported part

Changed 9 years ago by claus

Attachment: Instances.hs added

split source, importing part

comment:1 Changed 9 years ago by igloo

difficulty: Unknown
Milestone: 6.10.1

Thanks for the report

comment:2 Changed 9 years ago by simonpj

Resolution: fixed
Status: newclosed

I declare this fixed, as a result of

Wed Sep  3 13:02:28 BST 2008  simonpj@microsoft.com
  * Major change in compilation of instance declarations 
             (fix Trac #955, #2328)

Here are the timings

bash-3.2$ time ghc -c -fforce-recomp Instances.hs -package ghc

real	0m7.039s
user	0m6.546s
sys	0m0.361s
bash-3.2$ time ghc -c -fforce-recomp Instances0.hs -package ghc

real	0m1.271s
user	0m1.069s
sys	0m0.111s
bash-3.2$ time ghc -c -fforce-recomp All.hs -package ghc

real	0m8.727s
user	0m8.011s
sys	0m0.479s
bash-3.2$ wc *hs
  355  1200  9779 All.hs
  169   495  4559 Instances0.hs
  211   758  5678 Instances.hs
  735  2453 20016 total

I did residency measures too

  All.hs        109M
  Instances.hs   95M
  Instances0.hs  29M

Timings are longer with -O, but similarly additive.

In the files you supplied, I replaced

deriving instance Typeable1 DeprecDecl
deriving instance Data a => Data (DeprecDecl a)

by

deriving instance Typeable1 WarnDecl
deriving instance Data a => Data (WarnDecl a)

deriving instance Typeable WarningTxt
deriving instance Data WarningTxt

which is, I suppose, because package ghc has changed. Otherwise they are just as you supplied.

Simon

comment:3 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:4 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:5 Changed 8 years ago by simonmar

Type of failure: Compile-time performance bug
Note: See TracTickets for help on using tickets.