Gentoo Archives: gentoo-dev

From: heroxbd@g.o
To: gentoo-dev@l.g.o
Cc: Benda Xu <heroxbd@g.o>
Subject: [gentoo-dev] [PATCH] ghc-package.eclass: limit the ghc parallel jobs to 64.
Date: Fri, 06 Mar 2020 08:06:59
Message-Id: 20200306080559.202706-1-heroxbd@gentoo.org
From: Benda Xu <heroxbd@g.o>

  If ghc spawns too many C compilers, it will exhaust file descripters.

  In the reference, it was thought to be a macOS bug for aggressive fd
  limits.  But the ghc bug also applies to GNU/Linux, when ghc is
  asked to spawn, for example 256, jobs.

  This patch circumvents this ghc design flaw.

Reference: https://github.com/commercialhaskell/stack/issues/1177
Reference: https://github.com/commercialhaskell/stack/issues/1979
Signed-off-by: Benda Xu <heroxbd@g.o>
---
 eclass/ghc-package.eclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/eclass/ghc-package.eclass b/eclass/ghc-package.eclass
index 5361f09af1e9..d729f4a407b4 100644
--- a/eclass/ghc-package.eclass
+++ b/eclass/ghc-package.eclass
@@ -203,7 +203,9 @@ ghc-make-args() {
 		#    https://ghc.haskell.org/trac/ghc/ticket/9221#comment:57
 		# SMP is a requirement for parallel GC's gen0
 		# 'qb' balancing.
-		echo "-j$(makeopts_jobs) +RTS -A256M -qb0 -RTS"
+		local n=$(makeopts_jobs)
+		[[ ${n} -gt 64 ]] && n=64
+		echo "-j${n} +RTS -A256M -qb0 -RTS"
 		ghc_make_args=()
 	fi
 	echo "${ghc_make_args[@]}"
-- 
2.25.0

Replies