wip RawFilePath 2x git-annex find speedup
Finally builds (oh the agoncy of making it build), but still very unmergable, only Command.Find is included and lots of stuff is badly hacked to make it compile. Benchmarking vs master, this git-annex find is significantly faster! Specifically: num files old new speedup 48500 4.77 3.73 28% 12500 1.36 1.02 66% 20 0.075 0.074 0% (so startup time is unchanged) That's without really finishing the optimization. Things still to do: * Eliminate all the fromRawFilePath, toRawFilePath, encodeBS, decodeBS conversions. * Use versions of IO actions like getFileStatus that take a RawFilePath. * Eliminate some Data.ByteString.Lazy.toStrict, which is a slow copy. * Use ByteString for parsing git config to speed up startup. It's likely several of those will speed up git-annex find further. And other commands will certianly benefit even more.
This commit is contained in:
parent
6a97ff6b3a
commit
067aabdd48
61 changed files with 380 additions and 296 deletions
|
@ -9,6 +9,7 @@ module Command.Find where
|
|||
|
||||
import Data.Default
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.ByteString.Char8 as S8
|
||||
|
||||
import Command
|
||||
import Annex.Content
|
||||
|
@ -57,29 +58,29 @@ seek o = case batchOption o of
|
|||
(commandAction . startKeys o)
|
||||
(withFilesInGit (commandAction . go))
|
||||
=<< workTreeItems (findThese o)
|
||||
Batch fmt -> batchFilesMatching fmt go
|
||||
Batch fmt -> batchFilesMatching fmt (go . toRawFilePath)
|
||||
where
|
||||
go = whenAnnexed $ start o
|
||||
|
||||
-- only files inAnnex are shown, unless the user has requested
|
||||
-- others via a limit
|
||||
start :: FindOptions -> FilePath -> Key -> CommandStart
|
||||
start :: FindOptions -> RawFilePath -> Key -> CommandStart
|
||||
start o file key =
|
||||
stopUnless (limited <||> inAnnex key) $
|
||||
startingCustomOutput key $ do
|
||||
showFormatted (formatOption o) file $ ("file", file) : keyVars key
|
||||
showFormatted (formatOption o) file $ ("file", fromRawFilePath file) : keyVars key
|
||||
next $ return True
|
||||
|
||||
startKeys :: FindOptions -> (Key, ActionItem) -> CommandStart
|
||||
startKeys o (key, ActionItemBranchFilePath (BranchFilePath _ topf) _) =
|
||||
start o (getTopFilePath topf) key
|
||||
start o (toRawFilePath (getTopFilePath topf)) key
|
||||
startKeys _ _ = stop
|
||||
|
||||
showFormatted :: Maybe Utility.Format.Format -> String -> [(String, String)] -> Annex ()
|
||||
showFormatted :: Maybe Utility.Format.Format -> RawFilePath -> [(String, String)] -> Annex ()
|
||||
showFormatted format unformatted vars =
|
||||
unlessM (showFullJSON $ JSONChunk vars) $
|
||||
case format of
|
||||
Nothing -> liftIO $ putStrLn unformatted
|
||||
Nothing -> liftIO $ S8.putStrLn unformatted
|
||||
Just formatter -> liftIO $ putStr $
|
||||
Utility.Format.format formatter $
|
||||
M.fromList vars
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue