commercialhaskell / commercialhaskell/stack

Pass `-j` to GHC when building packages

Open
#4,046 8 comments 2 reactions 0 assignees View on GitHub
component: build type: enhancement type: performance
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### General summary/comments

When `stack` performs a build by default it does not pass `-j` to GHC, which causes GHC to build the modules within a package without parallelism. This is different from the `-j` option in `stack` itself, which affects how many packages can be built in parallel.

### Steps to reproduce

1. Select a package with a large number of independent modules such as `pandoc`. Clone the repo (`git clone https://github.com/jgm/pandoc.git`).
2. Run command `stack build` within the repo.
3. Observe that when building `pandoc`, GHC only uses one CPU core.
4. Now remove the previous build by `stack clean`.
5. Run command `stack build --ghc-options=-j`.
6. Observe that the GHC process uses > 100% CPU and the build completes faster overall.

### Expected

Stack automatically passes `-j` to GHC.

### Actual

Stack did not.

### Stack version

```
$ stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
```

### Method of installation

Official binary

### Further remarks

It should be noted that this could also be applied when building dependencies, although the interaction between this `-j` and stack's own task parallelism could complicate things.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.