Description
I can see that stack test
defaults to parallel builds. But that refers to parallelism between different test-suites, right? In the case of both builds and tests (with test-framework or tasty) there's the issue of "inner loop" parallelism within each build or test target. I suppose we can't parallelize the tests until we have some way for the build-tool to know it's a tasty/test-framework suite, not just exitcode-stdio-1.0
, but that still leaves build-parallelism. Does Stack currently pass -j
to GHC?
I haven't seen comprehensive benchmark numbers, but a small value like -j2
or -j4
for GHC offers some benefit. The current implementation is not scalable however (for example, I haven't seen anything good come of -j32
).
Nested parallelism of course raises the issue of N * N
jobs being spawned for N
cores. As long as its quadratic oversubscription and not exponential, I think this is not that big a problem for CPU usage, but it very often can create problems with memory usage (or hitting ulimits / max # of processes).
There are several related cabal issues, but it's a little hard to tell the current status with them spanning a lot of time and various merged and unmerged pull requests:
- build multiple packages in parallel haskell/cabal#440 -- mentions how Gentoo uses an estimate of current load to gate creation of new jobs
- Parallelise cabal build over modules haskell/cabal#976
- 'install -j': allow limiting the number of parallel linker invocations haskell/cabal#1572 -- some talk of using OS semaphors to manage shared compute resources. A draft of the related code appears here, in @23Skidoo's unmerged work.
-j
should build package components in parallel haskell/cabal#2623