make --fast disable the numcopies stats

Looking up the location log for every key is not the fastest operation..
This commit is contained in:
Joey Hess 2013-09-15 19:17:56 -04:00
parent a3bbda5bed
commit 9d366dc638
2 changed files with 25 additions and 14 deletions

View file

@ -59,8 +59,7 @@ newtype Variance = Variance Int
instance Show Variance where instance Show Variance where
show (Variance n) show (Variance n)
| n == 0 = "numcopies satisfied" | n >= 0 = "numcopies +" ++ show n
| n > 0 = "numcopies +" ++ show n
| otherwise = "numcopies " ++ show n | otherwise = "numcopies " ++ show n
-- cached info that multiple Stats use -- cached info that multiple Stats use
@ -92,19 +91,25 @@ start ps = do
globalStatus :: Annex () globalStatus :: Annex ()
globalStatus = do globalStatus = do
fast <- Annex.getState Annex.fast stats <- selStats global_fast_stats global_slow_stats
let stats = if fast
then global_fast_stats
else global_fast_stats ++ global_slow_stats
showCustom "status" $ do showCustom "status" $ do
evalStateT (mapM_ showStat stats) (StatInfo Nothing Nothing Nothing) evalStateT (mapM_ showStat stats) (StatInfo Nothing Nothing Nothing)
return True return True
localStatus :: FilePath -> Annex () localStatus :: FilePath -> Annex ()
localStatus dir = showCustom (unwords ["status", dir]) $ do localStatus dir = showCustom (unwords ["status", dir]) $ do
let stats = map (\s -> s dir) local_stats stats <- selStats (tostats local_fast_stats) (tostats local_slow_stats)
evalStateT (mapM_ showStat stats) =<< getLocalStatInfo dir evalStateT (mapM_ showStat stats) =<< getLocalStatInfo dir
return True return True
where
tostats = map (\s -> s dir)
selStats :: [Stat] -> [Stat] -> Annex [Stat]
selStats fast_stats slow_stats = do
fast <- Annex.getState Annex.fast
return $ if fast
then fast_stats
else fast_stats ++ slow_stats
{- Order is significant. Less expensive operations, and operations {- Order is significant. Less expensive operations, and operations
- that share data go together. - that share data go together.
@ -131,14 +136,17 @@ global_slow_stats =
, bloom_info , bloom_info
, backend_usage , backend_usage
] ]
local_stats :: [FilePath -> Stat] local_fast_stats :: [FilePath -> Stat]
local_stats = local_fast_stats =
[ local_dir [ local_dir
, const local_annex_keys , const local_annex_keys
, const local_annex_size , const local_annex_size
, const known_annex_keys , const known_annex_keys
, const known_annex_size , const known_annex_size
, const numcopies_stats ]
local_slow_stats :: [FilePath -> Stat]
local_slow_stats =
[ const numcopies_stats
] ]
stat :: String -> (String -> StatState String) -> Stat stat :: String -> (String -> StatState String) -> Stat
@ -306,14 +314,15 @@ cachedNumCopiesStats = numCopiesStats <$> get
getLocalStatInfo :: FilePath -> Annex StatInfo getLocalStatInfo :: FilePath -> Annex StatInfo
getLocalStatInfo dir = do getLocalStatInfo dir = do
fast <- Annex.getState Annex.fast
matcher <- Limit.getMatcher matcher <- Limit.getMatcher
(presentdata, referenceddata, numcopiesstats) <- (presentdata, referenceddata, numcopiesstats) <-
Command.Unused.withKeysFilesReferencedIn dir initial Command.Unused.withKeysFilesReferencedIn dir initial
(update matcher) (update matcher fast)
return $ StatInfo (Just presentdata) (Just referenceddata) (Just numcopiesstats) return $ StatInfo (Just presentdata) (Just referenceddata) (Just numcopiesstats)
where where
initial = (emptyKeyData, emptyKeyData, emptyNumCopiesStats) initial = (emptyKeyData, emptyKeyData, emptyNumCopiesStats)
update matcher key file vs@(presentdata, referenceddata, numcopiesstats) = update matcher fast key file vs@(presentdata, referenceddata, numcopiesstats) =
ifM (matcher $ FileInfo file file) ifM (matcher $ FileInfo file file)
( (,,) ( (,,)
<$> ifM (inAnnex key) <$> ifM (inAnnex key)
@ -321,7 +330,9 @@ getLocalStatInfo dir = do
, return presentdata , return presentdata
) )
<*> pure (addKey key referenceddata) <*> pure (addKey key referenceddata)
<*> updateNumCopiesStats key file numcopiesstats <*> if fast
then return numcopiesstats
else updateNumCopiesStats key file numcopiesstats
, return vs , return vs
) )

2
debian/changelog vendored
View file

@ -12,7 +12,7 @@ git-annex (4.20130912) UNRELEASED; urgency=low
sync. sync.
* addurl: Fix quvi audodetection, broken in last release. * addurl: Fix quvi audodetection, broken in last release.
* status: In local mode, displays information about variance from configured * status: In local mode, displays information about variance from configured
numcopies levels. numcopies levels. (--fast avoids calculating these)
-- Joey Hess <joeyh@debian.org> Thu, 12 Sep 2013 12:14:46 -0400 -- Joey Hess <joeyh@debian.org> Thu, 12 Sep 2013 12:14:46 -0400