Opened 6 years ago

Last modified 3 years ago

#8731 new bug

long compilation time for module with large data type and partial record selectors

Reported by: carter Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.1-rc1
Keywords: deriving-perf Cc: gidyn, erikd
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

in both ghc 7.6 and 7.8rc, the Constants module in LLVM-General-Pure (and a few other similar modules) have surprisingly long (and noticable!) compilation times.

This seems to related to how GHC handles a many constructor data type with overlapping field names.

the time is nearly the same for building a static module with O1 and O2

carter repoScratcher/bad-ast » time ghc Constant.hs -O2                                                                      1 ↵
[1 of 1] Compiling Constant         ( Constant.hs, Constant.o )
ghc Constant.hs -O2  7.52s user 0.23s system 99% cpu 7.755 total
carter repoScratcher/bad-ast » time ghc Constant.hs -O1
[1 of 1] Compiling Constant         ( Constant.hs, Constant.o )
ghc Constant.hs -O1  6.62s user 0.20s system 100% cpu 6.768 total

heck even with -O0 its slow (though not terrible)

carter repoScratcher/bad-ast » time ghc Constant.hs -O0
[1 of 1] Compiling Constant         ( Constant.hs, Constant.o )
ghc Constant.hs -O0  2.76s user 0.14s system 101% cpu 2.873 total

Seems like there might something wrong in how we handle data types like this, the complexity need not

Attachments (1)

Constant.hs (4.4 KB) - added by carter 6 years ago.
data type example module

Download all attachments as: .zip

Change History (16)

Changed 6 years ago by carter

Attachment: Constant.hs added

data type example module

comment:1 Changed 6 years ago by gidyn

Cc: gideon@… added

comment:2 Changed 6 years ago by carter

rwbarton (on irc) noted this single module also has a nearly 1mb object file! Also apparently most of the code generated / time might be related to the Read and Show instances. (i've not check the latter myself, but sounds plausible)

comment:3 Changed 6 years ago by thoughtpolice

Milestone: 7.8.2
Version: 7.8.1-rc1

I'm punting this to 7.8.2.

comment:4 Changed 6 years ago by thoughtpolice

Version: 7.8.1-rc1

comment:5 Changed 5 years ago by thoughtpolice

Milestone: 7.8.27.8.3

comment:6 Changed 5 years ago by thoughtpolice

Milestone: 7.8.37.10.1

comment:7 Changed 5 years ago by thomie

Timing results for the example from comment:1.

GHC -O1 -O2
7.4.2 4.9s 16s
7.6.3 5.0s 15s
7.8.3 4.4s 12s
7.9.20141113 4.4s 14s

Command: time ghc -fforce-recomp -O<n> Constant.hs

Compilation takes only about 1 second, with either -O1 or -O2, when I remove the deriving (Eq, Ord, Read, Show) clause from data Constant. The resulting object file is also much smallers: 100kb instead of 1mb.

Last edited 5 years ago by thomie (previous) (diff)

comment:8 Changed 5 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:9 Changed 4 years ago by gidyn

Cc: gideon@… removed

comment:10 Changed 4 years ago by gidyn

Cc: gidyn added

comment:11 Changed 4 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:12 Changed 4 years ago by bgamari

Looks like this may be related to instance deriving, perhaps a duplicate of #10980.

comment:13 Changed 4 years ago by ezyang

Keywords: deriving-perf added

comment:14 Changed 4 years ago by thomie

Milestone: 8.0.1

comment:15 Changed 3 years ago by erikd

Cc: erikd added
Note: See TracTickets for help on using tickets.