Opened 4 years ago

Last modified 7 months ago

#5522 new bug

mc03 -O -fliberate-case -fspec-constr runs out of memory

Reported by: btutt Owned by: simonpj
Priority: normal Milestone: 7.12.1
Component: Compiler Version: 7.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case: mc03
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

I noticed that test mc03 runs out of memory compiled with -O -fliberate-case -fspec-constr.

-O + either extra option on its own isn't enough to trigger the issue..

stage2 --info output:

$ ../inplace/bin/ghc-stage2.exe --info
 [("Project name","The Glorious Glasgow Haskell Compilation System")
 ,("GCC extra via C opts"," -fwrapv")
 ,("C compiler command","$topdir/../mingw/bin/gcc.exe")
 ,("C compiler flags","")
 ,("ar command","C:/MinGW/msys/1.0/home/bill/ghc-HEAD-github/inplace/mingw/bin/ar.exe")
 ,("ar flags","q")
 ,("ar supports at file","YES")
 ,("touch command","$topdir/touchy.exe")
 ,("dllwrap command","$topdir/../mingw/bin/dllwrap.exe")
 ,("windres command","$topdir/../mingw/bin/windres.exe")
 ,("perl command","$topdir/../perl/perl.exe")
 ,("Project version","7.3.20110927")
 ,("Booter version","7.0.2")
 ,("Stage","2")
 ,("Build platform","i386-unknown-mingw32")
 ,("Host platform","i386-unknown-mingw32")
 ,("Target platform","i386-unknown-mingw32")
 ,("Have interpreter","YES")
 ,("Object splitting supported","YES")
 ,("Have native code generator","YES")
 ,("Support SMP","YES")
 ,("Unregisterised","NO")
 ,("Tables next to code","YES")
 ,("RTS ways","l debug  thr thr_debug thr_l thr_p  dyn debug_dyn thr_dyn thr_debug_dyn")
 ,("Leading underscore","YES")
 ,("Debug on","False")
 ,("LibDir","C:\\MinGW\\msys\\1.0\\home\\bill\\ghc-HEAD-github\\inplace\\lib")
 ,("Global Package DB","C:\\MinGW\\msys\\1.0\\home\\bill\\ghc-HEAD-github\\inplace\\lib\\package.conf.d")
 ,("Gcc Linker flags","[]")
 ,("Ld Linker flags","[]")
 ]

ghc-HEAD was built with BuildFlavor=perf

Attachments (4)

5522.hs (2.1 KB) - added by igloo 4 years ago.
z6.hs (249 bytes) - added by igloo 4 years ago.
partial.core.1.z6 (15.5 KB) - added by igloo 4 years ago.
partial.core.2.z6 (65.7 KB) - added by igloo 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by igloo

  • Milestone set to 7.6.1
  • Owner set to igloo
  • Type of failure changed from Compile-time crash to Compile-time performance bug

Thanks for the report.

Reproduced with HEAD in testsuite/tests/deSugar/should_run:

$ ulimit -v 1024000
$ ghc  -fforce-recomp --make mc03 -O -fliberate-case -fspec-constr 
[1 of 1] Compiling Main             ( mc03.hs, mc03.o )
ghc-stage2: out of memory (requested 1048576 bytes)

Changed 4 years ago by igloo

Changed 4 years ago by igloo

Changed 4 years ago by igloo

Changed 4 years ago by igloo

comment:2 Changed 4 years ago by igloo

  • Owner changed from igloo to simonpj

I've attached a cut-down testcase 5522.hs:

$ ulimit -v 1024000
$ ghc -fforce-recomp --make 5522.hs -O -fliberate-case -fspec-constr
[1 of 1] Compiling Foo              ( 5522.hs, 5522.o )
ghc-stage2: out of memory (requested 1048576 bytes)

Also a smaller version of the same pattern, z6.hs, and its core before and after SpecConstr. It looks like the amount of core grows quadratically, due to the way that as well as the original binding (e.g. go_Xdn) we also get a binding specialised for the Int# case (e.g. $sgo_sgm).

So for example, in partial.core.2.z6 there are 7 uses of lvl_scs (which is [4]), and 11 uses of lvl_scu (which is [5]).

Simon, is this the expected behaviour when asking for this specialisation, or is it something that we should fix?

comment:3 Changed 3 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:4 Changed 13 months ago by thoughtpolice

  • Milestone changed from 7.6.2 to 7.10.1

Moving to 7.10.1.

comment:5 Changed 8 months ago by thomie

  • Architecture changed from x86 to Unknown/Multiple
  • difficulty set to Unknown
  • Operating System changed from Windows to Unknown/Multiple

The immediate issue here is fixed. Test 5522.hs from comment:2 does not run out of memory anymore.

The reason seems to be that HEAD now reduces monad comprehensions such as [x0 + x1 | x0 <- [0], x1 <- [1]] to just [1] at compile time, just as 7.8.3 and earlier already did with list comprehensions. Maybe the real bug is just covered up?

This is the output of ghc -fforce-recomp --make 5522.hs -O -fliberate-case -fspec-constr -ddump-simpl:

==================== Tidy Core ====================
Result size of Tidy Core = {terms: 7, types: 5, coercions: 0}

Foo.output1 :: Int
[GblId,
 Caf=NoCafRefs,
 Str=DmdType m,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
Foo.output1 = GHC.Types.I# 450

output :: [Int]
[GblId,
 Caf=NoCafRefs,
 Str=DmdType m2,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
output = GHC.Types.: @ Int Foo.output1 (GHC.Types.[] @ Int)

comment:6 Changed 7 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.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.

Note: See TracTickets for help on using tickets.