Simon Peyton Jones pushed to branch wip/T23559 at Glasgow Haskell Compiler / GHC Commits: 89a3718e by Simon Peyton Jones at 2025-11-26T14:59:23+00:00 Switch off specialisation in ExactPrint In !15057 (where we re-introduced -fpolymoprhic-specialisation) we found that ExactPrint's compile time blew up by a factor of 5. It turned out to be caused by bazillions of specialisations of `markAnnotated`. Since ExactPrint isn't perf-critical, it does not seem worth taking the performance hit, so this patch switches off specialisation in this one module. - - - - - 85b1977f by Simon Peyton Jones at 2025-11-26T14:59:32+00:00 Switch -fpolymorphic-specialisation on by default This patch addresses #23559. Now that !10479 has landed and #26329 is fixed, we can switch on polymorphic specialisation by default, addressing a bunch of other tickets listed in #23559. Metric changes: * CoOpt_Singleton: +4% compiler allocations: we just get more specialisations * info_table_map_perf: -20% decrease in compiler allocations. This is caused by using -fno-specialise in ExactPrint.hs Without that change we get a 4x blow-up in compile time; see !15058 for details Metric Decrease: info_table_map_perf Metric Increase: CoOpt_Singletons - - - - - 4 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Flags.hs - docs/users_guide/using-optimisation.rst - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -1268,6 +1268,7 @@ optLevelFlags -- see Note [Documenting optimisation flags] , ([1,2], Opt_CfgBlocklayout) -- Experimental , ([1,2], Opt_Specialise) + , ([1,2], Opt_PolymorphicSpecialisation) -- Now on by default (#23559) , ([1,2], Opt_CrossModuleSpecialise) , ([1,2], Opt_InlineGenerics) , ([1,2], Opt_Strictness) ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -909,6 +909,7 @@ optimisationFlags = EnumSet.fromList , Opt_SpecialiseAggressively , Opt_CrossModuleSpecialise , Opt_StaticArgumentTransformation + , Opt_PolymorphicSpecialisation , Opt_CSE , Opt_StgCSE , Opt_StgLiftLams ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -1325,10 +1325,7 @@ as such you shouldn't need to set any of them explicitly. A flag :reverse: -fno-polymorphic-specialisation :category: - :default: off - - Warning, this feature is highly experimental and may lead to incorrect runtime - results. Use at your own risk (:ghc-ticket:`23469`, :ghc-ticket:`23109`, :ghc-ticket:`21229`, :ghc-ticket:`23445`). + :default: on Enable specialisation of function calls to known dictionaries with free type variables. The created specialisation will abstract over the type variables free in the dictionary. ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -19,6 +19,13 @@ {-# LANGUAGE UndecidableInstances #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance {-# OPTIONS_GHC -Wno-incomplete-uni-patterns -Wno-incomplete-record-updates #-} +-- We switch off specialisation in this module. Otherwise we get lots of functions +-- specialised on lots of (GHC syntax tree) data types. Compilation time allocation +-- (at least with -fpolymorphic-specialisation; see !15058) blows up from 17G to 108G. +-- Bad! ExactPrint is not a performance-critical module so it's not worth taking the +-- largely-fruitless hit in compile time. +{-# OPTIONS_GHC -fno-specialise #-} + module ExactPrint ( ExactPrint(..) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ecf0dbebf541e533a1beff1aec767a1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ecf0dbebf541e533a1beff1aec767a1... You're receiving this email because of your account on gitlab.haskell.org.