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
|
@ -102,7 +102,10 @@ pipeNullSplit params repo = do
|
|||
return (filter (not . L.null) $ L.split 0 s, cleanup)
|
||||
|
||||
{- Reads lazily, but converts each part to a strict ByteString for
|
||||
- convenience. -}
|
||||
- convenience.
|
||||
-
|
||||
- FIXME the L.toStrict makes a copy, more expensive than ideal.
|
||||
-}
|
||||
pipeNullSplit' :: [CommandParam] -> Repo -> IO ([S.ByteString], IO Bool)
|
||||
pipeNullSplit' params repo = do
|
||||
(s, cleanup) <- pipeNullSplit params repo
|
||||
|
@ -116,6 +119,9 @@ pipeNullSplitStrict params repo = do
|
|||
pipeNullSplitZombie :: [CommandParam] -> Repo -> IO [L.ByteString]
|
||||
pipeNullSplitZombie params repo = leaveZombie <$> pipeNullSplit params repo
|
||||
|
||||
pipeNullSplitZombie' :: [CommandParam] -> Repo -> IO [S.ByteString]
|
||||
pipeNullSplitZombie' params repo = leaveZombie <$> pipeNullSplit' params repo
|
||||
|
||||
{- Doesn't run the cleanup action. A zombie results. -}
|
||||
leaveZombie :: (a, IO Bool) -> a
|
||||
leaveZombie = fst
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Git.FilePath (
|
||||
TopFilePath,
|
||||
|
@ -33,6 +34,7 @@ import Git
|
|||
import qualified System.FilePath.Posix
|
||||
import GHC.Generics
|
||||
import Control.DeepSeq
|
||||
import qualified Data.ByteString as S
|
||||
|
||||
{- A RawFilePath, relative to the top of the git repository. -}
|
||||
newtype TopFilePath = TopFilePath { getTopFilePath :: FilePath }
|
||||
|
@ -45,8 +47,9 @@ data BranchFilePath = BranchFilePath Ref TopFilePath
|
|||
deriving (Show, Eq, Ord)
|
||||
|
||||
{- Git uses the branch:file form to refer to a BranchFilePath -}
|
||||
descBranchFilePath :: BranchFilePath -> String
|
||||
descBranchFilePath (BranchFilePath b f) = fromRef b ++ ':' : (getTopFilePath f)
|
||||
descBranchFilePath :: BranchFilePath -> S.ByteString
|
||||
descBranchFilePath (BranchFilePath b f) =
|
||||
encodeBS' (fromRef b) <> ":" <> toRawFilePath (getTopFilePath f)
|
||||
|
||||
{- Path to a TopFilePath, within the provided git repo. -}
|
||||
fromTopFilePath :: TopFilePath -> Git.Repo -> FilePath
|
||||
|
|
|
@ -36,5 +36,5 @@ encode :: RawFilePath -> S.ByteString
|
|||
encode s = encodeBS $ "\"" ++ encode_c (decodeBS s) ++ "\""
|
||||
|
||||
{- For quickcheck. -}
|
||||
prop_encode_decode_roundtrip :: RawFilePath -> Bool
|
||||
prop_encode_decode_roundtrip s = s == decode (encode s)
|
||||
prop_encode_decode_roundtrip :: FilePath -> Bool
|
||||
prop_encode_decode_roundtrip s = s == fromRawFilePath (decode (encode (toRawFilePath s)))
|
||||
|
|
|
@ -65,8 +65,8 @@ branchRef = underBase "refs/heads"
|
|||
- Prefixing the file with ./ makes this work even if in a subdirectory
|
||||
- of a repo.
|
||||
-}
|
||||
fileRef :: FilePath -> Ref
|
||||
fileRef f = Ref $ ":./" ++ f
|
||||
fileRef :: RawFilePath -> Ref
|
||||
fileRef f = Ref $ ":./" ++ fromRawFilePath f
|
||||
|
||||
{- Converts a Ref to refer to the content of the Ref on a given date. -}
|
||||
dateRef :: Ref -> RefDate -> Ref
|
||||
|
@ -74,7 +74,7 @@ dateRef (Ref r) (RefDate d) = Ref $ r ++ "@" ++ d
|
|||
|
||||
{- A Ref that can be used to refer to a file in the repository as it
|
||||
- appears in a given Ref. -}
|
||||
fileFromRef :: Ref -> FilePath -> Ref
|
||||
fileFromRef :: Ref -> RawFilePath -> Ref
|
||||
fileFromRef (Ref r) f = let (Ref fr) = fileRef f in Ref (r ++ fr)
|
||||
|
||||
{- Checks if a ref exists. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue