Keep a running InstalledPackageIndex to skip expensive per-package ghc-pkg calls#11767
Keep a running InstalledPackageIndex to skip expensive per-package ghc-pkg calls#11767sheaf wants to merge 1 commit intohaskell:masterfrom
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!
| -------------------------------------------------------------------------------- | ||
|
|
There was a problem hiding this comment.
Is this separator between imports and the rest of the module needed?
There was a problem hiding this comment.
I find it helpful to clearly demarcate the module header from the rest of the file, especially in this case with the CPP just above. I'd prefer to keep it if that's OK with you.
There was a problem hiding this comment.
This position is just after the last import. I'm a vim user and I can get to that location with "/^import" then "N".
I wonder if HLS provides a fold/unfold for all of the imports?
|
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. |
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.
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.