benchmarked numcopies .gitattributes in preferred content
Checking .gitattributes adds a full minute to a git annex find looking for files that don't have enough copies. 2:25 increasts to 3:27. I feel this is too much of a slowdown to justify making it the default. So, exposed two versions of the preferred content expression, a slow one and a fast but approximate one. I'm using the approximate one in the default preferred content expressions to avoid slowing down the assistant.
This commit is contained in:
parent
f7cdc40f7b
commit
f2713a3bb9
8 changed files with 41 additions and 35 deletions
39
Limit.hs
39
Limit.hs
|
@ -178,29 +178,26 @@ limitCopies want = case split ":" want of
|
|||
| "+" `isSuffixOf` s = (>=) <$> readTrustLevel (beginning s)
|
||||
| otherwise = (==) <$> readTrustLevel s
|
||||
|
||||
{- Adds a limit to match files that need more copies made.
|
||||
-
|
||||
- Does not look at annex.numcopies .gitattributes, because that
|
||||
- would require querying git check-attr every time a preferred content
|
||||
- expression is checked, which would probably be quite slow.
|
||||
-}
|
||||
addNumCopiesNeeded :: String -> Annex ()
|
||||
addNumCopiesNeeded = addLimit . limitNumCopiesNeeded
|
||||
{- Adds a limit to match files that need more copies made. -}
|
||||
addLackingCopies :: Bool -> String -> Annex ()
|
||||
addLackingCopies approx = addLimit . limitLackingCopies approx
|
||||
|
||||
limitNumCopiesNeeded :: MkLimit
|
||||
limitNumCopiesNeeded want = case readish want of
|
||||
Just needed -> Right $ \notpresent -> checkKey $
|
||||
handle needed notpresent
|
||||
Nothing -> Left "bad value for numcopiesneeded"
|
||||
limitLackingCopies :: Bool -> MkLimit
|
||||
limitLackingCopies approx want = case readish want of
|
||||
Just needed -> Right $ \notpresent mi -> flip checkKey mi $
|
||||
handle mi needed notpresent
|
||||
Nothing -> Left "bad value for number of lacking copies"
|
||||
where
|
||||
handle needed notpresent key = do
|
||||
gv <- getGlobalNumCopies
|
||||
case gv of
|
||||
Nothing -> return False
|
||||
Just (NumCopies numcopies) -> do
|
||||
us <- filter (`S.notMember` notpresent)
|
||||
<$> (trustExclude UnTrusted =<< Remote.keyLocations key)
|
||||
return $ numcopies - length us >= needed
|
||||
handle mi needed notpresent key = do
|
||||
NumCopies numcopies <- if approx
|
||||
then approxNumCopies
|
||||
else case mi of
|
||||
MatchingKey _ -> approxNumCopies
|
||||
MatchingFile fi -> getGlobalFileNumCopies $ matchFile fi
|
||||
us <- filter (`S.notMember` notpresent)
|
||||
<$> (trustExclude UnTrusted =<< Remote.keyLocations key)
|
||||
return $ numcopies - length us >= needed
|
||||
approxNumCopies = fromMaybe defaultNumCopies <$> getGlobalNumCopies
|
||||
|
||||
{- Adds a limit to skip files not believed to be present in all
|
||||
- repositories in the specified group. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue