[Haskell-cafe] Cabal: Can only one processor core be used?

Henning Thielemann lemming at henning-thielemann.de
Tue Apr 2 11:38:41 UTC 2024


On Tue, 2 Apr 2024, Volker Wysk wrote:

> I've searched the web and the cabal user guide on how to use more processor
> cores for compilation via cabal. I couldn't find anything.

$ cabal install -j3

or

$ fgrep jobs ~/.cabal/config
jobs: 3


> Cabal compilation times can be a pain. It can't be that you can use only 
> one processor core with cabal, can it ..?

There are two places where you can increase the use of multiple cores. The 
one above controls the number of packages to be compiled in parallel, 
whereas

$ cabal install --ghc-option=-j3

means that each instance of GHC compiles up to three modules in parallel.

As far as I know it is currently not possible to interleave compilation of 
modules and packages. I.e. optimally we would only need one 'jobs' option 
and then Cabal and GHC manage to fill the working queue with any module 
from any package. This would certainly require to run GHC in a server 
mode.


However, without a fast storage for temporary files you will hardly see an 
actual speedup. I use to mount a ram disk with tmpfs at /ram and then 
compile with

$ cabal install -j3 --ghc-option=-j3 --builddir=/ram/cabal


More information about the Haskell-Cafe mailing list