git.iko.soy/typeable/nixpkgs
on master help sign in
haskell: tune generic-builder for more parallel build performance

Raise the maximum number of cores used for parallel building from 4 to 16. Increase the size of the allocation area for GHC's garbage collector from 1 MiB to 64 MiB. See https://www.twitch.tv/videos/611899011 for the motivation for this change.

commitccb81f56cf6b5f1769c32b3638783717c7746694 authorPeter Simons <simons@cryp.to> dateThu 7 May 2020, 12:48 (7 years ago) parent0d9dbee
1 file changed+9−11
pkgs/development/haskell-modules/generic-builder.nix+9−11
pkgs/development/haskell-modules/generic-builder.nix+9−11
@@ -48,12 +48,8 @@ in
4848, isExecutable ? false, isLibrary ? !isExecutable
4949, jailbreak ? false
5050, license
51−# We cannot enable -j<n> parallelism for libraries because GHC is far more
52−# likely to generate a non-determistic library ID in that case. Further
53−# details are at <https://github.com/peti/ghc-library-id-bug>.
54−#
55−# Currently disabled for aarch64. See https://ghc.haskell.org/trac/ghc/ticket/15449.
56−, enableParallelBuilding ? ((stdenv.lib.versionOlder "7.8" ghc.version && !isLibrary) || stdenv.lib.versionOlder "8.0.1" ghc.version) && !(stdenv.buildPlatform.isAarch64)
51+ # aarch64 sometimes crashes for -jn with n>1: https://ghc.haskell.org/trac/ghc/ticket/15449
52+, enableParallelBuilding ? !stdenv.buildPlatform.isAarch64
5753, maintainers ? []
5854, doCoverage ? false
5955, doHaddock ? !(ghc.isHaLVM or false)
@@ -82,7 +78,7 @@ in
8278 # same package in the (recursive) dependencies of the package being
8379 # built. Will delay failures, if any, to compile time.
8480 allowInconsistentDependencies ? false
85−, maxBuildCores ? 4 # GHC usually suffers beyond -j4. https://ghc.haskell.org/trac/ghc/ticket/9221
81+, maxBuildCores ? 16 # more cores usually don't improve performance: https://ghc.haskell.org/trac/ghc/ticket/9221
8682, # If set to true, this builds a pre-linked .o file for this Haskell library.
8783 # This can make it slightly faster to load this library into GHCi, but takes
8884 # extra disk space and compile time.
@@ -181,6 +177,8 @@ let
181177 (optionalString enableHsc2hsViaAsm "--hsc2hs-option=--via-asm")
182178 ];
183179
180+ parallelBuildingFlags = "-j$NIX_BUILD_CORES" + optionalString stdenv.isLinux " +RTS -A64M -RTS";
181+
184182 crossCabalFlagsString =
185183 stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);
186184
@@ -199,7 +197,7 @@ let
199197 "--package-db=$packageConfDir"
200198 (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}")
201199 (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
202− (optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES")
200+ (optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}")
203201 (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
204202 (enableFeature (enableDeadCodeElimination && !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && (versionAtLeast "8.0.1" ghc.version)) "split-objs")
205203 (enableFeature enableLibraryProfiling "library-profiling")
@@ -227,9 +225,9 @@ let
227225
228226 setupCompileFlags = [
229227 (optionalString (!coreSetup) "-${nativePackageDbFlag}=$setupPackageConfDir")
230− (optionalString (isGhcjs || isHaLVM || versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES")
231− # https://github.com/haskell/cabal/issues/2398
232− (optionalString (versionOlder "7.10" ghc.version && !isHaLVM) "-threaded")
228+ (optionalString enableParallelBuilding (parallelBuildingFlags))
229+ "-threaded" # https://github.com/haskell/cabal/issues/2398
230+ "-rtsopts" # allow us to pass RTS flags to the generated Setup executable
233231 ];
234232
235233 isHaskellPkg = x: x ? isHaskellLibrary;