Does anyone know how to get cabal install
to exploit parallelism? I'm compiling with GHC, and while I don't know if GHC itself can do parallel builds, surely cabal install
could run multiple compilations in parallel, no? At least for distinct, independent packages?
Does anyone know if it is possible and how to do it?
There was a Google Summer of Code project this summer to parallelize cabal-install
. While it hasn't been merged into the mainline yet, the linked article provides instructions for grabbing the source and building it yourself.
I'm the one who was working on this Summer of Code project. The patches have been sent to Duncan, but he hasn't reviewed them yet. Note that my code works at the package granularity, so you won't get any speedup when building a single package. I'm currently working on a parallel wrapper around ghc --make
, which will solve this problem (I hope to get it merged into the mainline cabal-install
eventually).
Update (Feb. 2012): Duncan has reviewed my patches, I need to incorporate his feedback and resubmit them. I hope to get this done before the end of this month.
Update (Apr. 2012): I've updated my patches in response to Duncan's comments. The new code is a bit slower, but requires much less changes to the Cabal library.
Update (Jun. 2012): Duncan Coutts just merged the parallel branch into Cabal HEAD. Parallel install will be available in the next cabal-install
release.
Update (Oct. 2012): cabal-install
1.16.0 has just been released. This is the first official release that includes my parallel patches.
Completing Mikhail Glushenkov's answer to document the usage a bit:
As of cabal 1.16.0, you can now use
cabal install -j [pkgs…]
This defaults to one job per core. It also gives much cleaner output.
You can make parallel installs the default with:
echo "jobs: $(getconf _NPROCESSORS_ONLN)" >> ~/.cabal/config
Or (cabal-install 1.18+):
echo 'jobs: $ncpus' >> ~/.cabal/config
Get the latest cabal-install with:
cabal update
cabal install cabal-install --bindir ~/bin --upgrade-dependencies