diff options
author | Peter Simons <simons@cryp.to> | 2020-05-07 12:48:51 +0200 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2020-05-08 21:11:47 +0200 |
commit | ccb81f56cf6b5f1769c32b3638783717c7746694 (patch) | |
tree | 40cd2152af7b14aad2622a55be78b871cec0a747 /pkgs/development/haskell-modules/generic-builder.nix | |
parent | 0d9dbeef23792514d057c27d5a5a944b31762c39 (diff) | |
download | nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.tar nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.tar.gz nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.tar.bz2 nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.tar.lz nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.tar.xz nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.tar.zst nixlib-ccb81f56cf6b5f1769c32b3638783717c7746694.zip |
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.
Diffstat (limited to 'pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r-- | pkgs/development/haskell-modules/generic-builder.nix | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index ac22f903c9b5..49cbe02b71e5 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -48,12 +48,8 @@ in , isExecutable ? false, isLibrary ? !isExecutable , jailbreak ? false , license -# We cannot enable -j<n> parallelism for libraries because GHC is far more -# likely to generate a non-determistic library ID in that case. Further -# details are at <https://github.com/peti/ghc-library-id-bug>. -# -# Currently disabled for aarch64. See https://ghc.haskell.org/trac/ghc/ticket/15449. -, enableParallelBuilding ? ((stdenv.lib.versionOlder "7.8" ghc.version && !isLibrary) || stdenv.lib.versionOlder "8.0.1" ghc.version) && !(stdenv.buildPlatform.isAarch64) + # aarch64 sometimes crashes for -jn with n>1: https://ghc.haskell.org/trac/ghc/ticket/15449 +, enableParallelBuilding ? !stdenv.buildPlatform.isAarch64 , maintainers ? [] , doCoverage ? false , doHaddock ? !(ghc.isHaLVM or false) @@ -82,7 +78,7 @@ in # same package in the (recursive) dependencies of the package being # built. Will delay failures, if any, to compile time. allowInconsistentDependencies ? false -, maxBuildCores ? 4 # GHC usually suffers beyond -j4. https://ghc.haskell.org/trac/ghc/ticket/9221 +, maxBuildCores ? 16 # more cores usually don't improve performance: https://ghc.haskell.org/trac/ghc/ticket/9221 , # If set to true, this builds a pre-linked .o file for this Haskell library. # This can make it slightly faster to load this library into GHCi, but takes # extra disk space and compile time. @@ -181,6 +177,8 @@ let (optionalString enableHsc2hsViaAsm "--hsc2hs-option=--via-asm") ]; + parallelBuildingFlags = "-j$NIX_BUILD_CORES" + optionalString stdenv.isLinux " +RTS -A64M -RTS"; + crossCabalFlagsString = stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags); @@ -199,7 +197,7 @@ let "--package-db=$packageConfDir" (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}") (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names") - (optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES") + (optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}") (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp") (enableFeature (enableDeadCodeElimination && !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && (versionAtLeast "8.0.1" ghc.version)) "split-objs") (enableFeature enableLibraryProfiling "library-profiling") @@ -227,9 +225,9 @@ let setupCompileFlags = [ (optionalString (!coreSetup) "-${nativePackageDbFlag}=$setupPackageConfDir") - (optionalString (isGhcjs || isHaLVM || versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES") - # https://github.com/haskell/cabal/issues/2398 - (optionalString (versionOlder "7.10" ghc.version && !isHaLVM) "-threaded") + (optionalString enableParallelBuilding (parallelBuildingFlags)) + "-threaded" # https://github.com/haskell/cabal/issues/2398 + "-rtsopts" # allow us to pass RTS flags to the generated Setup executable ]; isHaskellPkg = x: x ? isHaskellLibrary; |