-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use ghc-pkg recache #5639
Comments
Revisiting this again since it would be a big win for curator, which often unregisters hundreds/thousands of packages. I think the code in question is https://github.com/commercialhaskell/stack/blob/master/src/Stack/Build/Execute.hs#L863 |
@juhp, based on https://downloads.haskell.org/~ghc/9.2.8/docs/html/users_guide/packages.html#package-management-the-ghc-pkg-command for I am (perhaps naively) assuming that I am also assuming that when a small number of packages are being removed - presumably the usual case for most users - |
Thanks @mpilgrem
I think so yes
I believe so: I suspect it may update the db, package by package perhaps. I don't know exactly why unregister is soo slow, but I think it is a well-known ghc-pkg issue.
I don't believe that is true. AFAIK the performance of recache is never worse than register/unregister. For example if I install or remove 500 Fedora Haskell packages say, I don't even notice recache being run at the end. |
It seems to me that the problem with "unregister" : pkgarg_strs@(_:_) -> do
forM_ pkgarg_strs $ \pkgarg_str -> do
pkgarg <- readPackageArg as_arg pkgarg_str
unregisterPackage pkgarg verbosity cli force That is, 'unregister packages' is 'unregister one package after another', and (if I understand correctly) each 'unregister' also checks for newly-broken packages and performs a recache - and each 'remove a package' also filters a (possibly long) list of packages. Extracts: unregisterPackage :: PackageArg -> Verbosity -> [Flag] -> Force -> IO ()
unregisterPackage = modifyPackage RemovePackage
modifyPackage
:: (InstalledPackageInfo -> DBOp)
-> PackageArg
-> Verbosity
-> [Flag]
-> Force
-> IO ()
modifyPackage fn pkgarg verbosity my_flags force = do
...
-- ...but do consistency checks with regards to the full stack
old_broken = brokenPackages (allPackagesInStack db_stack)
rest_of_stack = filter ((/= db_name) . location) db_stack
new_stack = new_db_ro : rest_of_stack
new_broken = brokenPackages (allPackagesInStack new_stack)
newly_broken = filter ((`notElem` map installedUnitId old_broken)
. installedUnitId) new_broken
...
when (not (null newly_broken)) $
dieOrForceAll force ("unregistering would break the following packages: "
++ unwords (map displayQualPkgId newly_broken))
changeDB verbosity cmds db db_stack
recache :: Verbosity -> [Flag] -> IO ()
recache verbosity my_flags = do
...
changeDB verbosity [] db_to_operate_on _db_stack I suppose you don't want to lose the checking for newly-broken packages, but you only want to do it once for each 'bulk' unregister. |
It seems to me that what would be ideal is:
I think I have a pull request (https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11142) for an 'efficient' |
Thanks @mpilgrem for the analysis and the MR - this sounds great!! BTW I curious about |
@juhp, I think when (not (null newly_broken)) $
dieOrForceAll force ("unregistering would break the following packages: "
++ unwords (map displayQualPkgId newly_broken))
dieOrForceAll :: Force -> String -> IO ()
dieOrForceAll ForceAll s = ignoreError s
dieOrForceAll _other s = dieForcible s That is, |
Notes for myself on Stack's unregistering generally:
|
Really big thank you for this, Mike! ❤️ |
Fix #5639 Backport efficient ghc-pkg unregister
ghc-pkg [un]register
is very slow, specially when many packages are involved.Would it not be possible for stack to use a single
ghc-pkg recache
instead,which is way faster when there are a large number of packages being added/removed.
The stackage build typically unregisters 100's of packages and this takes a very long time with
unregister
(often 30min or more).(In Fedora we use recache instead of unregister/register and it has sped package updates very much.)
The text was updated successfully, but these errors were encountered: