haskell / haskell/cabal

Duplicate project imports slow down the build

Open
#10,512 0 comments 0 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

When a project has duplicate imports the build is slower than it could be[^1].

To see this in action, I've created a `woops` project, the same as the `yops` one (the Y-forking one from #10508) but every `.project` or `.config` also imports `https://www.stackage.org/lts-21.25/cabal.config`. The former takes `12 s` to `cabal build --dry-run` and the later takes `200 ms`. If I add one import from stackage to the root of the `yops` project, its build takes `425 ms`.

```
$ ghc --numeric-version
9.4.8

$ time cabal run cabal-install:exe:cabal -- build --dry-run \
--project-file=cabal-testsuite/PackageTests/ConditionalAndImport/woops-0.project
Resolving dependencies...
Warning: this is a debug build of cabal-install with assertions enabled.
When using configuration from:
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- woops-0.project
- woops-2.config
- woops-4.config
- woops-4.config
- woops-6.config
- woops-6.config
- woops-6.config
- woops-8.config
- woops-8.config
- woops-8.config
- woops-8.config
- woops/woops-1.config
- woops/woops-3.config
- woops/woops-3.config
- woops/woops-5.config
- woops/woops-5.config
- woops/woops-5.config
- woops/woops-7.config
- woops/woops-7.config
- woops/woops-7.config
- woops/woops-7.config
- woops/woops-9.config
- woops/woops-9.config
- woops/woops-9.config
- woops/woops-9.config
- woops/woops-9.config
The following errors occurred:
- The package directory '.' does not contain any .cabal file.

________________________________________________________
Executed in 12.08 secs fish external
usr time 2.94 secs 0.00 micros 2.94 secs
sys time 0.45 secs 802.00 micros 0.45 secs
```

```
$ time cabal run cabal-install:exe:cabal -- build --dry-run \
--project-file=cabal-testsuite/PackageTests/ConditionalAndImport/yops-0.project
Warning: this is a debug build of cabal-install with assertions enabled.
When using configuration from:
- yops-0.project
- yops-2.config
- yops-4.config
- yops-4.config
- yops-6.config
- yops-6.config
- yops-6.config
- yops-8.config
- yops-8.config
- yops-8.config
- yops-8.config
- yops/yops-1.config
- yops/yops-3.config
- yops/yops-3.config
- yops/yops-5.config
- yops/yops-5.config
- yops/yops-5.config
- yops/yops-7.config
- yops/yops-7.config
- yops/yops-7.config
- yops/yops-7.config
- yops/yops-9.config
- yops/yops-9.config
- yops/yops-9.config
- yops/yops-9.config
- yops/yops-9.config
The following errors occurred:
- The package directory '.' does not contain any .cabal file.

________________________________________________________
Executed in 200.73 millis fish external
usr time 148.65 millis 0.00 micros 148.65 millis
sys time 52.03 millis 692.00 micros 51.33 millis

$ echo "import: https://www.stackage.org/lts-21.25/cabal.config" \
>> cabal-testsuite/PackageTests/ConditionalAndImport/yops-0.project

$ time cabal run cabal-install:exe:cabal -- build --dry-run \
--project-file=cabal-testsuite/PackageTests/ConditionalAndImport/yops-0.project
Warning: this is a debug build of cabal-install with assertions enabled.
When using configuration from:
- https://www.stackage.org/lts-21.25/cabal.config
- yops-0.project
- yops-2.config
- yops-4.config
- yops-4.config
- yops-6.config
- yops-6.config
- yops-6.config
- yops-8.config
- yops-8.config
- yops-8.config
- yops-8.config
- yops/yops-1.config
- yops/yops-3.config
- yops/yops-3.config
- yops/yops-5.config
- yops/yops-5.config
- yops/yops-5.config
- yops/yops-7.config
- yops/yops-7.config
- yops/yops-7.config
- yops/yops-7.config
- yops/yops-9.config
- yops/yops-9.config
- yops/yops-9.config
- yops/yops-9.config
- yops/yops-9.config
The following errors occurred:
- The package directory '.' does not contain any .cabal file.

________________________________________________________
Executed in 425.02 millis fish external
usr time 210.23 millis 0.00 micros 210.23 millis
sys time 49.17 millis 717.00 micros 48.45 millis
```

[^1]: #9933 tries to avoid this by making duplicate imports an error.

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.