Building a package is slow
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
I recently discovered that building packages is surprisingly more costly than building modules. See https://github.com/commercialhaskell/stack/issues/2831 for a benchmark and results. The takeaway is this:

I chased that behavior down to `cabal configure` and `cabal build`, so the problem isn't really with Stack. That made me wonder about how long it takes to build a package with Cabal, so I wrote [a benchmark](https://gist.github.com/tfausak/e431b194eb4374184281ae1769004638) for that. Here are the raw results:
```
benchmarking cabal sandbox init; cabal sandbox delete
time 152.6 ms (146.5 ms .. 156.6 ms)
0.998 R² (0.992 R² .. 1.000 R²)
mean 155.7 ms (152.5 ms .. 159.4 ms)
std dev 4.734 ms (2.695 ms .. 6.772 ms)
variance introduced by outliers: 12% (moderately inflated)
benchmarking cabal sandbox init; cabal build; cabal sandbox delete
time 1.414 s (1.362 s .. NaN s)
1.000 R² (0.999 R² .. 1.000 R²)
mean 1.433 s (1.422 s .. 1.443 s)
std dev 17.97 ms (271.9 as .. 18.36 ms)
variance introduced by outliers: 19% (moderately inflated)
benchmarking cabal build
time 495.2 ms (448.5 ms .. 532.5 ms)
0.999 R² (0.996 R² .. 1.000 R²)
mean 502.3 ms (495.4 ms .. 507.5 ms)
std dev 8.000 ms (0.0 s .. 9.039 ms)
variance introduced by outliers: 19% (moderately inflated)
```
What I take away from that is this: Building an empty package with a cold cache takes 1.4 seconds on my machine. A warm cache brings that down to 0.5 seconds. Both of those seem high, but especially the former. Are these results expected?
Contributor guide
Assessment
This issue has not been assessed yet.