Keep a running InstalledPackageIndex to skip expensive per-package ghc-pkg calls#11767
Conversation
f27441c to
06795ae
Compare
|
This was a bit subtle to write, and getting it wrong means that we pass an incomplete or incorrect |
|
Since the title of this PR mentions replacing "expensive" ghc-pkg calls, I am curious if there is any fast, back-of-envelope timings of what sorts of gains one can expect from this change. |
I will get back to you with more precise measurements but for typical packages this can save over half of the time spent in configure. Taken with #11768 I am seeing typical configure times go from ~3s to ~0.5s. |
Mikolaj
left a comment
There was a problem hiding this comment.
Great job! Looks plausible to me.
ulysses4ever
left a comment
There was a problem hiding this comment.
The caching strategy is straightforward and looks good. The relation to some ghc-pkg calls is indirect (you can't see it in the diff), so it's unclear to me. I'd appreciate if it was clarified, to which end I leave a comment for the changelog below. Thanks!
|
Re-marking as draft, as I have been using a version of |
|
I have attempted to fix the issue I was seeing with the latest push to the branch. I will do a bit more testing locally to make sure things are working as expected. |
79f2edd to
b9ac63a
Compare
|
I ran more tests and it revealed some issues when resuming interrupted builds. I changed the approach: now |
|
Asking for re-review for the latest round of changes, see e.g. this diff. |
|
Kindly asking whether @Mikolaj @ulysses4ever @philderbeast might take another look, this diff shows the changes since last time. |
|
I can take a look on the weekend |
Mikolaj
left a comment
There was a problem hiding this comment.
Looks just as plausible to me as last time. Good catch with the fixes.
|
I would like to land this for the next |
ulysses4ever
left a comment
There was a problem hiding this comment.
Looks very clean. Let's try it.
We extract 'computePackageInfoFromIndex' from the Cabal 'computePackageInfo' function, which allows cabal-install to use a running 'InstalledPackageIndex' instead of having to repeatedly query ghc-pkg (once per package). Several cabal-install functions now pass around a 'TVar InstalledPackageIndex' which keeps track of the 'InstalledPackageIndex' used for building a project. Each time a dependency gets registered, we update this 'TVar', and read from it to obtain an 'InstalledPackageIndex' to pass to the Cabal configure function, skipping slow calls to 'ghc-pkg'. For more details, please see Note [Per-project InstalledPackageIndex] in Distribution.Client.ProjectBuilding.
Merge Queue Status
This pull request spent 11 minutes 21 seconds in the queue, including 2 seconds running CI. Required conditions to merge
|
Building on the in-library refactor that landed in 6867dd5, this patch extracts
computePackageInfoFromIndexfrom the CabalcomputePackageInfofunction, which allows cabal-install to use a runningInstalledPackageIndexinstead of having to repeatedly query ghc-pkg, once per package.Several cabal-install functions now pass around a
TVar InstalledPackageIndexwhich keeps track of theInstalledPackageIndexused for building a project. Each time a dependency gets registered, we update thisTVar, and read from it to obtain anInstalledPackageIndexto pass to the Cabal configure function, skipping slow calls toghc-pkg.Template Α: This PR modifies behaviour or interface
ghc-pkgfar less.