Compiling Stage0 HsInstances and DynFlags with -O slows down Hadrian build unnecessarily
Most Hadrian build flavours compile Stage0 compiler modules with -O, but HsInstances and DynFlags compile so slowly as to outweigh their increased performance elsewhere in the build. Exact times vary, but both take on the order of minutes to compile single threaded, with high wall clock times (still on the order of minutes for HsInstances).
Compiling them instead with -O0 for Stage0 significantly reduces build time and should not affect the resulting Stage1 binaries, though at least in the case of the quickest flavour, both DynFlags and HsInstances are compiled with -O0 for Stage1 anyway.
I discuss the results and the process of investigating these files a little more in my HSoC update blog.
|Modules with -O0 added at Stage0||Mean time||Num Trials||Speedup|
Steps to reproduce
The times above were produced with these commands:
./hadrian/build.stack.sh clean ./hadrian/build.stack.sh -c -j -B --flavour=quickest --profile
To add -O0 to these modules only in Stage0, change the following in
hadrian/src/Settings/Packages.hs (starting at line 50)
, builder (Ghc CompileHs) ? mconcat [ inputs ["//GHC.hs", "//GhcMake.hs"] ? arg "-fprof-auto" , input "//Parser.hs" ? pure ["-fno-ignore-interface-pragmas", "-fcmm-sink" ] ]
, builder (Ghc CompileHs) ? mconcat [ inputs ["//GHC.hs", "//GhcMake.hs"] ? arg "-fprof-auto" , input "//Parser.hs" ? pure ["-fno-ignore-interface-pragmas", "-fcmm-sink" ] , inputs ["//HsInstances.hs", "//DynFlags.hs"] ? stage0 ? pure ["-O0"] ]
- GHC version used: Bootstrapping with GHC 8.6.5 using Stack
- Operating System: Antergos Linux
- System Architecture: x86-64