Opened 22 months ago

Last modified 22 months ago

#14738 new bug

Investigate performance of CoreTidy

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

Description

Considering the following profile output (compiling https://ghc.haskell.org/trac/ghc/attachment/ticket/14683/Grammar.hs):

	Thu Jan 25 13:11 2018 Time and Allocation Profiling Report  (Final)

	   ghc-stage2 +RTS -p -RTS -B/home/tobias/well-typed/devel/ghc/inplace/lib Grammar.hs -ddump-stg -ddump-simpl -ddump-to-file -fforce-recomp

	total time  =       20.99 secs   (20989 ticks @ 1000 us, 1 processor)
	total alloc = 29,250,375,256 bytes  (excludes profiling overheads)

COST CENTRE           MODULE     SRC                                                 %time %alloc

CoreTidy              HscMain    compiler/main/HscMain.hs:1253:27-67                  24.2   28.5
Stg2Stg               HscMain    compiler/main/HscMain.hs:1489:12-44                  20.3   24.2
simplCast             Simplify   compiler/simplCore/Simplify.hs:871:62-87             18.7   15.9
tc_rn_src_decls       TcRnDriver compiler/typecheck/TcRnDriver.hs:(494,4)-(556,7)      9.0    6.9
addCoerce-pushCoTyArg Simplify   compiler/simplCore/Simplify.hs:(1236,12)-(1237,72)    7.4    6.4
subst_ty              TyCoRep    compiler/types/TyCoRep.hs:2237:28-32                  4.3    5.1
zonkTopDecls          TcRnDriver compiler/typecheck/TcRnDriver.hs:(445,16)-(446,43)    1.4    1.1
coercionKind          Coercion   compiler/types/Coercion.hs:1725:3-7                   1.3    3.0
simplExprF1-Lam       Simplify   compiler/simplCore/Simplify.hs:896:5-39               1.0    1.1

...the amount of time spent in CoreTidy is striking, and should be investigated.

Change History (3)

comment:1 Changed 22 months ago by tdammers

Cc: tdammers added

comment:2 Changed 22 months ago by tdammers

The problem seems to mysteriously go away on newer commits. Adding more cost centres to GHC HEAD, I've found that CoreTidy hardly shows up in the profile at all, and practically all the remaining slowdown comes from code in Simplify.hs, which I believe #14737 is about.

comment:3 Changed 22 months ago by tdammers

Profile, based on GHC HEAD + some changes from #11735 + added SCCs, compiling Grammar.hs:

	Mon Feb  5 12:47 2018 Time and Allocation Profiling Report  (Final)

	   ghc-stage2 +RTS -p -RTS -B/home/tobias/well-typed/devel/ghc/inplace/lib Grammar.hs -fforce-recomp

	total time  =       12.73 secs   (12733 ticks @ 1000 us, 1 processor)
	total alloc = 14,413,041,648 bytes  (excludes profiling overheads)

COST CENTRE             MODULE     SRC                                                 %time %alloc

addCoerce-pushCoTyArg   Simplify   compiler/simplCore/Simplify.hs:1234:70-90            46.7   45.7
tc_rn_src_decls         TcRnDriver compiler/typecheck/TcRnDriver.hs:(494,4)-(556,7)     12.2   14.0
subst_ty                TyCoRep    compiler/types/TyCoRep.hs:2265:28-32                  7.0   10.4
tidyTopBinds            TidyPgm    compiler/main/TidyPgm.hs:370:21-82                    3.3    3.5
writeIface              HscMain    compiler/main/HscMain.hs:1279:9-45                    3.2    0.2
coercionKind            Coercion   compiler/types/Coercion.hs:1735:3-7                   3.0    6.0
zonkTopDecls            TcRnDriver compiler/typecheck/TcRnDriver.hs:(445,16)-(446,43)    2.1    2.2
simplExprF1-Lam         Simplify   compiler/simplCore/Simplify.hs:896:5-39               1.7    2.2
simplCast-simplCoercion Simplify   compiler/simplCore/Simplify.hs:1224:57-77             1.6    1.5
deSugar                 HscMain    compiler/main/HscMain.hs:511:7-44                     1.5    1.3
findExternalRules       TidyPgm    compiler/main/TidyPgm.hs:366:23-77                    1.1    0.2
Parser                  HscMain    compiler/main/HscMain.hs:(316,5)-(384,20)             1.1    1.6
simplIdF                Simplify   compiler/simplCore/Simplify.hs:868:61-79              1.0    0.5
simplCast-addCoerce     Simplify   compiler/simplCore/Simplify.hs:1225:53-71             1.0    1.0
Note: See TracTickets for help on using tickets.