New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass -j
to GHC when building packages
#4046
Comments
I think Stack knows enough about the build plan that it could be somewhat smart about this. For example, if you have 8 CPUs and 100 dependencies to build, it would start off with |
I am in favor of this (as a person who recompiles a lot), but I would like to request this to be at first an optional flag that's not enabled by default. The reason is that I use |
@k-bx I've never seen this fail, and I've been using this to compile everything since last year. That's including compiling dependencies using |
I'm glad that it worked for you, but I think we'd better split the adoption into two steps, one being non-default so that more people would start testing it, and then make it a default eventually. I'll check when I'll have an opportunity, but I think things were getting broken especially often when I cancelled the build. |
Great! Indeed I seldom if ever cancel a build; so that might be why I don't see any issues. I think I will be producing a PR in the next few days. But I'm new to the stack code base. Is there anything special that I should take note of before contributing? |
I'd love this |
I've asked about GHC's stack purge
Measure-Command -Expression {stack build | Out-Default} with stack purge
Measure-Command -Expression {stack build --ghc-options -j | Out-Default} the latter is about 16% faster than the former on my Windows PC. |
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 instack
itself, which affects how many packages can be built in parallel.Steps to reproduce
pandoc
. Clone the repo (git clone https://github.com/jgm/pandoc.git
).stack build
within the repo.pandoc
, GHC only uses one CPU core.stack clean
.stack build --ghc-options=-j
.Expected
Stack automatically passes
-j
to GHC.Actual
Stack did not.
Stack version
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.The text was updated successfully, but these errors were encountered: