1 |
commit: b3b64a95b9653963a2868278fd0130858a9eb9f0 |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Sep 2 09:26:43 2016 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 2 09:29:51 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b3b64a95 |
7 |
|
8 |
haskell-cabal.eclass: unleash full parallelism of parallel ghc |
9 |
|
10 |
I've explored scalability of 'ghc --make -j' a bit in |
11 |
https://ghc.haskell.org/trac/ghc/ticket/9221 |
12 |
|
13 |
Some takeaways: |
14 |
- never specify -j<N> with N > CPU. garbage collector threads |
15 |
waste kernel time running sched_yield() |
16 |
- GHC allocates A Lot: large nursery decreases GC interruptions. |
17 |
We fix it with '-A256M' |
18 |
- for large nursery enabling work-stealing makes GC finish faster |
19 |
on each collection cycle. |
20 |
We fix it with -qb0 |
21 |
|
22 |
While at it move HCFLAGS setup after parallel defaults. |
23 |
That allows user to override defaults with own HCFLAGS. |
24 |
|
25 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
26 |
|
27 |
eclass/haskell-cabal.eclass | 20 ++++++++------------ |
28 |
1 file changed, 8 insertions(+), 12 deletions(-) |
29 |
|
30 |
diff --git a/eclass/haskell-cabal.eclass b/eclass/haskell-cabal.eclass |
31 |
index c1a1330..94ef7f3 100644 |
32 |
--- a/eclass/haskell-cabal.eclass |
33 |
+++ b/eclass/haskell-cabal.eclass |
34 |
@@ -372,24 +372,20 @@ cabal-configure() { |
35 |
cabalconf+=($(cabal-constraint "ghc")) |
36 |
fi |
37 |
|
38 |
+ # parallel on all available cores |
39 |
+ if ghc-supports-parallel-make; then |
40 |
+ # It should have been just -j$(makeopts_jobs) |
41 |
+ # but GHC does not yet have nice defaults: |
42 |
+ # https://ghc.haskell.org/trac/ghc/ticket/9221#comment:57 |
43 |
+ cabalconf+=(--ghc-options="-j$(makeopts_jobs) +RTS -A256M -qb0 -RTS") |
44 |
+ fi |
45 |
+ |
46 |
local option |
47 |
for option in ${HCFLAGS} |
48 |
do |
49 |
cabalconf+=(--ghc-option="$option") |
50 |
done |
51 |
|
52 |
- # parallel on all available cores |
53 |
- if ghc-supports-parallel-make; then |
54 |
- local max_jobs=$(makeopts_jobs) |
55 |
- |
56 |
- # limit to very small value, as parallelism |
57 |
- # helps slightly, but makes things severely worse |
58 |
- # when amount of threads is Very Large. |
59 |
- [[ ${max_jobs} -gt 4 ]] && max_jobs=4 |
60 |
- |
61 |
- cabalconf+=(--ghc-option=-j"$max_jobs") |
62 |
- fi |
63 |
- |
64 |
# Building GHCi libs on ppc64 causes "TOC overflow". |
65 |
if use ppc64; then |
66 |
cabalconf+=(--disable-library-for-ghci) |