cache negative lookups of global numcopies and mincopies

Speeds up eg git-annex sync --content by up to 50%. When it does not need
to transfer or drop anything, it now noops a lot more quickly.

I didn't see anything else in sync --content noop loop that could really
be sped up. It has to cat git objects to keys, stat object files, etc.

Sponsored-by: unqueued on Patreon
This commit is contained in:
Joey Hess 2023-06-06 14:15:47 -04:00
parent 4437e187e6
commit 3c15e0f7a0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 38 additions and 6 deletions

View file

@ -45,22 +45,22 @@ setGlobalMinCopies new = do
{- Value configured in the numcopies log. Cached for speed. -}
getGlobalNumCopies :: Annex (Maybe NumCopies)
getGlobalNumCopies = maybe globalNumCopiesLoad (return . Just)
getGlobalNumCopies = maybe globalNumCopiesLoad return
=<< Annex.getState Annex.globalnumcopies
{- Value configured in the mincopies log. Cached for speed. -}
getGlobalMinCopies :: Annex (Maybe MinCopies)
getGlobalMinCopies = maybe globalMinCopiesLoad (return . Just)
getGlobalMinCopies = maybe globalMinCopiesLoad return
=<< Annex.getState Annex.globalmincopies
globalNumCopiesLoad :: Annex (Maybe NumCopies)
globalNumCopiesLoad = do
v <- getLog numcopiesLog
Annex.changeState $ \s -> s { Annex.globalnumcopies = v }
Annex.changeState $ \s -> s { Annex.globalnumcopies = Just v }
return v
globalMinCopiesLoad :: Annex (Maybe MinCopies)
globalMinCopiesLoad = do
v <- getLog mincopiesLog
Annex.changeState $ \s -> s { Annex.globalmincopies = v }
Annex.changeState $ \s -> s { Annex.globalmincopies = Just v }
return v