[Git][ghc/ghc][master] hadrian: replace default -H32m/-H64m with -O64M to improve mutator productivity
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 87d8f6c2 by Cheng Shao at 2026-01-18T10:01:30-05:00 hadrian: replace default -H32m/-H64m with -O64M to improve mutator productivity Most hadrian build flavours pass `-H32m`/`-H64m` to GHC as conventional wisdom to improve mutator productivity and reduce GC overhead. They were inherited from the legacy Make build system, and there used to be make flags to instrument a build process with `-Rghc-timing` option to collect GC stats of each GHC run from stderr. It's time to revisit whether there are better defaults for `-H32m`/`-H64m`, and this patch changes it to `-O64M` which indeed improves mutator productivity based on real statistics. `-O64M` is more aggressive than `-H64m`; it allows the old generation to grow to at least 64M before triggering major GC and reduces major GC runs. The stats of a clean build with `validate` flavour and `-H64m`: ``` h64m.log matched RTS stat lines: 5499 sum MUT cpu : 2400.808 s sum GC cpu : 1378.292 s sum MUT elapsed : 2788.253 s sum GC elapsed : 1389.233 s GC/MUT cpu ratio : 0.574 (GC is 57.4% of MUT) GC/MUT elapsed ratio : 0.498 (GC is 49.8% of MUT) GC fraction of (MUT+GC) cpu : 36.5% GC fraction of (MUT+GC) elapsed : 33.3% per-line GC/MUT cpu ratio: median 0.691, p90 1.777 per-line GC/MUT elapsed ratio: median 0.519, p90 1.081 ``` The stats of a clean build with `validate` flavour and `-O64M`: ``` o64m.log matched RTS stat lines: 5499 sum MUT cpu : 2377.383 s sum GC cpu : 1127.146 s sum MUT elapsed : 2758.857 s sum GC elapsed : 1135.587 s GC/MUT cpu ratio : 0.474 (GC is 47.4% of MUT) GC/MUT elapsed ratio : 0.412 (GC is 41.2% of MUT) GC fraction of (MUT+GC) cpu : 32.2% GC fraction of (MUT+GC) elapsed : 29.2% per-line GC/MUT cpu ratio: median 0.489, p90 1.099 per-line GC/MUT elapsed ratio: median 0.367, p90 0.806 ``` Mutator time is roughly in the same ballpark, but GC CPU time has reduced by 18.22%, and mutator productivity has increased from 63.5% to 67.8%. - - - - - 10 changed files: - hadrian/doc/flavours.md - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Benchmark.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Flavours/GhcInGhci.hs - hadrian/src/Settings/Flavours/Performance.hs - hadrian/src/Settings/Flavours/Quick.hs - hadrian/src/Settings/Flavours/QuickCross.hs - hadrian/src/Settings/Flavours/Quickest.hs - hadrian/src/Settings/Flavours/Validate.hs Changes: ===================================== hadrian/doc/flavours.md ===================================== @@ -37,8 +37,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>default<br></td> <td> </td> - <td>-O<br>-H32m<br></td> - <td>-O2<br>-H32m</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS<br></td> + <td>-O2<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-haddock</td> <td></td> @@ -49,8 +49,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>quick</td> <td> </td> - <td>-O0<br>-H64m</td> - <td>-O0<br>-H64m</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-O</td> <td>-O2</td> @@ -61,8 +61,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>quick-validate</td> <td></td> - <td>-O0<br>-H64m<br>-Werror</td> - <td>-O0<br>-H64m<br>-Werror</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS<br>-Werror</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS<br>-Werror</td> <td></td> <td>-O</td> <td>-O2</td> @@ -73,8 +73,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>quick-debug</td> <td></td> - <td>-O0<br>-H64m</td> - <td>-O0<br>-H64m</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-O</td> <td>-O2</td> @@ -85,8 +85,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>quickest</td> <td></td> - <td>-O0<br>-H64m</td> - <td>-O0<br>-H64m</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td></td> <td>-O</td> @@ -97,8 +97,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>perf</td> <td> Yes (on supported platforms) </td> - <td>-O<br>-H64m</td> - <td>-O<br>-H64m</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-O2</td> <td>-O2</td> @@ -109,8 +109,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>release (same as perf with -haddock and +no_self_recomp+hash_unit_ids)</td> <td></td> - <td>-O<br>-H64m</td> - <td>-O<br>-H64m</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-O2</td> <td>-O2</td> @@ -121,8 +121,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>bench</td> <td></td> - <td>-O<br>-H64m</td> - <td>-O<br>-H64m</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-O2</td> <td>-O2</td> @@ -133,8 +133,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>devel1</td> <td></td> - <td>-O<br>-H64m</td> - <td>-O<br>-H64m</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-dcore-lint</td> <td>-O0<br>-DDEBUG</td> @@ -145,8 +145,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>devel2</td> <td></td> - <td>-O<br>-H64m</td> - <td>-O<br>-H64m</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS</td> <td></td> <td>-dcore-lint</td> <td>-O2</td> @@ -157,7 +157,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>validate</td> <td></td> - <td>-O0<br>-H64m</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> <td>-fllvm-fill-undef-with-garbage<br>-fcheck-prim-bounds</td> <td></td> <td>-O<br>-dcore-lint<br>-dno-debug-output</td> @@ -169,7 +169,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>slow-validate</td> <td></td> - <td>-O0<br>-H64m</td> + <td>-O0<br>+RTS<br>-O64M<br>-RTS</td> <td>-fllvm-fill-undef-with-garbage</td> <td></td> <td>-O<br>-dcore-lint<br>-dno-debug-output</td> @@ -181,8 +181,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH <tr> <th>static</td> <td></td> - <td>-O<br>-H64m<br>-fPIC -static</td> - <td>-O<br>-H64m<br>-fPIC -static</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS<br>-fPIC -static</td> + <td>-O<br>+RTS<br>-O64M<br>-RTS<br>-fPIC -static</td> <td></td> <td>-O2</td> <td>-O2</td> ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -274,7 +274,7 @@ defaultSourceArgs :: SourceArgs defaultSourceArgs = SourceArgs { hsDefault = mconcat [ stage0 ? arg "-O" , notStage0 ? arg "-O2" - , arg "-H32m" ] + , pure ["+RTS", "-O64M", "-RTS"] ] , hsLibrary = notStage0 ? arg "-haddock" , hsCompiler = mempty , hsGhc = mempty } ===================================== hadrian/src/Settings/Flavours/Benchmark.hs ===================================== @@ -16,7 +16,7 @@ benchmarkFlavour = defaultFlavour benchmarkArgs :: Args benchmarkArgs = sourceArgs SourceArgs - { hsDefault = pure ["-O", "-H64m"] + { hsDefault = pure ["-O", "+RTS", "-O64M", "-RTS"] , hsLibrary = pure ["-O2"] -- TODO: We should really pass -O2 when notStage0. Otherwise, we aren't -- really measuring the overhead of a potential new optimisation we want ===================================== hadrian/src/Settings/Flavours/Development.hs ===================================== @@ -26,7 +26,7 @@ developmentFlavour ghcStage = defaultFlavour developmentArgs :: Stage -> Args developmentArgs ghcStage = sourceArgs SourceArgs - { hsDefault = mconcat [ pure ["-O", "-H64m"], + { hsDefault = mconcat [ pure ["-O", "+RTS", "-O64M", "-RTS"], -- Disable optimization when building Cabal; -- this saves many minutes of build time. package cabal ? pure ["-O0"]] ===================================== hadrian/src/Settings/Flavours/GhcInGhci.hs ===================================== @@ -22,7 +22,7 @@ ghcInGhciFlavour = defaultFlavour ghciArgs :: Args ghciArgs = sourceArgs SourceArgs { hsDefault = mconcat $ - [ pure ["-O0", "-H64m"] + [ pure ["-O0", "+RTS", "-O64M", "-RTS"] ] , hsLibrary = mempty , hsCompiler = mempty ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -12,7 +12,7 @@ performanceFlavour = splitSections $ enableLateCCS $ defaultFlavour performanceArgs :: Args performanceArgs = sourceArgs SourceArgs - { hsDefault = pure ["-O", "-H64m"] + { hsDefault = pure ["-O", "+RTS", "-O64M", "-RTS"] , hsLibrary = orM [notStage0, cross] ? arg "-O2" , hsCompiler = pure ["-O2"] , hsGhc = mconcat ===================================== hadrian/src/Settings/Flavours/Quick.hs ===================================== @@ -34,7 +34,7 @@ quickFlavour = defaultFlavour quickArgs :: Args quickArgs = sourceArgs SourceArgs - { hsDefault = mconcat [ pure ["-O0", "-H64m"] ] + { hsDefault = mconcat [ pure ["-O0", "+RTS", "-O64M", "-RTS"] ] , hsLibrary = notStage0 ? arg "-O" , hsCompiler = stage0 ? arg "-O2" , hsGhc = stage0 ? arg "-O" } ===================================== hadrian/src/Settings/Flavours/QuickCross.hs ===================================== @@ -32,7 +32,7 @@ quickCrossFlavour = defaultFlavour quickCrossArgs :: Args quickCrossArgs = sourceArgs SourceArgs { hsDefault = mconcat $ - [ pure ["-O0", "-H64m"] + [ pure ["-O0", "+RTS", "-O64M", "-RTS"] ] , hsLibrary = notStage0 ? mconcat [ arg "-O", arg "-fllvm" ] , hsCompiler = stage0 ? arg "-O2" ===================================== hadrian/src/Settings/Flavours/Quickest.hs ===================================== @@ -19,7 +19,7 @@ quickestFlavour = defaultFlavour quickestArgs :: Args quickestArgs = sourceArgs SourceArgs { hsDefault = mconcat $ - [ pure ["-O0", "-H64m"] + [ pure ["-O0", "+RTS", "-O64M", "-RTS"] ] , hsLibrary = mempty , hsCompiler = stage0 ? arg "-O" ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -16,11 +16,12 @@ validateFlavour = enableLinting $ quickValidateFlavour validateArgs :: Args validateArgs = sourceArgs SourceArgs - { hsDefault = mconcat [ stage0 ? pure ["-O0", "-H64m"] + { hsDefault = mconcat [ stage0 ? pure ["-O0"] -- See #11487 , notStage0 ? arg "-fllvm-fill-undef-with-garbage" , notStage0 ? arg "-dno-debug-output" , notStage0 ? arg "-fcheck-prim-bounds" + , pure ["+RTS", "-O64M", "-RTS"] ] , hsLibrary = pure ["-O"] , hsCompiler = mconcat [ stage0 ? pure ["-O2"] @@ -37,7 +38,7 @@ slowValidateFlavour = validateFlavour quickValidateArgs :: Args quickValidateArgs = sourceArgs SourceArgs - { hsDefault = mempty + { hsDefault = pure ["+RTS", "-O64M", "-RTS"] , hsLibrary = pure [ "-O" ] , hsCompiler = mconcat [ stage0 ? arg "-O2", notStage0 ? arg "-O"] , hsGhc = pure [ "-O", "-hide-all-packages" ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/87d8f6c236996b228e758c5eab2a565e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/87d8f6c236996b228e758c5eab2a565e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)