add cache for getNumMinCopiesAttr
Optimises balanced=groupname:lackingcopies at the expense of a tiny slowdown to lackingcopies=number and git-annex fsck and import. Sponsored-by: k0ld
This commit is contained in:
parent
1435f6ff82
commit
88a09a7c05
2 changed files with 15 additions and 7 deletions
2
Annex.hs
2
Annex.hs
|
@ -197,6 +197,7 @@ data AnnexState = AnnexState
|
||||||
, checkignorehandle :: Maybe (ResourcePool CheckIgnoreHandle)
|
, checkignorehandle :: Maybe (ResourcePool CheckIgnoreHandle)
|
||||||
, globalnumcopies :: Maybe (Maybe NumCopies)
|
, globalnumcopies :: Maybe (Maybe NumCopies)
|
||||||
, globalmincopies :: Maybe (Maybe MinCopies)
|
, globalmincopies :: Maybe (Maybe MinCopies)
|
||||||
|
, nummincopiesattrcache :: Maybe (OsPath, (Maybe NumCopies, Maybe MinCopies))
|
||||||
, limit :: ExpandableMatcher Annex
|
, limit :: ExpandableMatcher Annex
|
||||||
, timelimit :: Maybe (Duration, POSIXTime)
|
, timelimit :: Maybe (Duration, POSIXTime)
|
||||||
, sizelimit :: Maybe (TVar Integer)
|
, sizelimit :: Maybe (TVar Integer)
|
||||||
|
@ -253,6 +254,7 @@ newAnnexState c r = do
|
||||||
, checkignorehandle = Nothing
|
, checkignorehandle = Nothing
|
||||||
, globalnumcopies = Nothing
|
, globalnumcopies = Nothing
|
||||||
, globalmincopies = Nothing
|
, globalmincopies = Nothing
|
||||||
|
, nummincopiesattrcache = Nothing
|
||||||
, limit = BuildingMatcher []
|
, limit = BuildingMatcher []
|
||||||
, timelimit = Nothing
|
, timelimit = Nothing
|
||||||
, sizelimit = Nothing
|
, sizelimit = Nothing
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex numcopies configuration and checking
|
{- git-annex numcopies configuration and checking
|
||||||
-
|
-
|
||||||
- Copyright 2014-2024 Joey Hess <id@joeyh.name>
|
- Copyright 2014-2025 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -181,12 +181,18 @@ getGlobalFileNumCopies f = fromSourcesOr defaultNumCopies
|
||||||
]
|
]
|
||||||
|
|
||||||
getNumMinCopiesAttr :: OsPath -> Annex (Maybe NumCopies, Maybe MinCopies)
|
getNumMinCopiesAttr :: OsPath -> Annex (Maybe NumCopies, Maybe MinCopies)
|
||||||
getNumMinCopiesAttr file =
|
getNumMinCopiesAttr file = Annex.getState Annex.nummincopiesattrcache >>= \case
|
||||||
checkAttrs ["annex.numcopies", "annex.mincopies"] file >>= \case
|
Just (cfile, v) | cfile == file -> return v
|
||||||
(n:m:[]) -> return
|
_ -> checkAttrs ["annex.numcopies", "annex.mincopies"] file >>= \case
|
||||||
( configuredNumCopies <$> readish n
|
(n:m:[]) -> do
|
||||||
, configuredMinCopies <$> readish m
|
let v =
|
||||||
)
|
( configuredNumCopies <$> readish n
|
||||||
|
, configuredMinCopies <$> readish m
|
||||||
|
)
|
||||||
|
Annex.changeState $ \s -> s
|
||||||
|
{ Annex.nummincopiesattrcache = Just (file, v)
|
||||||
|
}
|
||||||
|
return v
|
||||||
_ -> error "internal"
|
_ -> error "internal"
|
||||||
|
|
||||||
{- Checks if numcopies are satisfied for a file by running a comparison
|
{- Checks if numcopies are satisfied for a file by running a comparison
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue