Stack: extra-deps' clones as many times the repository as there are subdirs

Created on 7 Oct 2020  ·  7Comments  ·  Source: commercialhaskell/stack

General summary/comments (optional)

When I specify, in extra-deps, a repository with many subdirs, the repository is clone many times.

Steps to reproduce

Build a project with this package.yml part:

extra-deps:
- git: https://github.com/theam/aws-lambda-haskell-runtime.git
  commit: 6aef017c1621c828a47dc98eae12d84818a8d45c
- git: https://github.com/brendanhay/amazonka.git
  commit: 020bc7bde47bb235e448c76088dc44d6cec13e9b
  subdirs:
    - gen
    - core
    - test
    - examples
    - amazonka

Expected

I expect only one cloning.

Actual

The repository is cloned once by subdir.

Partial output

Stack version

$ stack --version
Version 2.3.3, Git revision cb44d51bed48b723a5deb08c3348c0b3ccfc437e x86_64 hpack-0.33.0

Method of installation

curl -sSL https://get.haskellstack.org/ | sh
build pantry enhancement

Most helpful comment

Another data point is cardano-wallet, which takes ~30 minutes just to clone all repos on my machine (1mb/s, say nothing :cry:). Cabal takes about 5.

All 7 comments

Thanks for reporting @blackheaven.

Just a note: I've given this the type: enhancement label rather than type: bug because it's surprising and sub-optimal (but not workflow-breaking) behavior.

Pantry caches repos but it looks like it does it per subdirectory - https://github.com/commercialhaskell/pantry/blob/master/src/Pantry/Storage.hs#L236

Nice catch.

I am curious, what are the rationals for that strategy?

@snoyberg could you share them?

The model of pantry is that a tree represents a single package. This allows caching only what is needed for that package, and more frequent cache hits.

IMO, the best way to improve this is to tweak pantry to aggregate all packages coming from the same repo and collect all the trees at once. I don't think it would be too invasive a change, and shouldn't require any changes at all to the overall model.

It makes sense, thank you for that explanation.

Another data point is cardano-wallet, which takes ~30 minutes just to clone all repos on my machine (1mb/s, say nothing :cry:). Cabal takes about 5.

Was this page helpful?
0 / 5 - 0 ratings