use filepath-bytestring for annex object manipulations
git-annex find is now RawFilePath end to end, no string conversions. So is git-annex get when it does not need to get anything. So this is a major milestone on optimisation. Benchmarks indicate around 30% speedup in both commands. Probably many other performance improvements. All or nearly all places where a file is statted use RawFilePath now.
This commit is contained in:
parent
bdec7fed9c
commit
c19211774f
53 changed files with 324 additions and 234 deletions
|
@ -22,7 +22,6 @@ module Utility.InodeCache (
|
|||
readInodeCache,
|
||||
showInodeCache,
|
||||
genInodeCache,
|
||||
genInodeCache',
|
||||
toInodeCache,
|
||||
likeInodeCacheWeak,
|
||||
|
||||
|
@ -182,12 +181,8 @@ readInodeCache s = case words s of
|
|||
return $ InodeCache $ InodeCachePrim i sz (MTimeHighRes t)
|
||||
_ -> Nothing
|
||||
|
||||
genInodeCache :: FilePath -> TSDelta -> IO (Maybe InodeCache)
|
||||
genInodeCache :: RawFilePath -> TSDelta -> IO (Maybe InodeCache)
|
||||
genInodeCache f delta = catchDefaultIO Nothing $
|
||||
toInodeCache delta f =<< getFileStatus f
|
||||
|
||||
genInodeCache' :: RawFilePath -> TSDelta -> IO (Maybe InodeCache)
|
||||
genInodeCache' f delta = catchDefaultIO Nothing $
|
||||
toInodeCache delta (fromRawFilePath f) =<< R.getFileStatus f
|
||||
|
||||
toInodeCache :: TSDelta -> FilePath -> FileStatus -> IO (Maybe InodeCache)
|
||||
|
@ -208,8 +203,8 @@ toInodeCache (TSDelta getdelta) f s
|
|||
- Its InodeCache at the time of its creation is written to the cache file,
|
||||
- so changes can later be detected. -}
|
||||
data SentinalFile = SentinalFile
|
||||
{ sentinalFile :: FilePath
|
||||
, sentinalCacheFile :: FilePath
|
||||
{ sentinalFile :: RawFilePath
|
||||
, sentinalCacheFile :: RawFilePath
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
|
@ -226,8 +221,8 @@ noTSDelta = TSDelta (pure 0)
|
|||
|
||||
writeSentinalFile :: SentinalFile -> IO ()
|
||||
writeSentinalFile s = do
|
||||
writeFile (sentinalFile s) ""
|
||||
maybe noop (writeFile (sentinalCacheFile s) . showInodeCache)
|
||||
writeFile (fromRawFilePath (sentinalFile s)) ""
|
||||
maybe noop (writeFile (fromRawFilePath (sentinalCacheFile s)) . showInodeCache)
|
||||
=<< genInodeCache (sentinalFile s) noTSDelta
|
||||
|
||||
data SentinalStatus = SentinalStatus
|
||||
|
@ -256,7 +251,7 @@ checkSentinalFile s = do
|
|||
Just new -> return $ calc old new
|
||||
where
|
||||
loadoldcache = catchDefaultIO Nothing $
|
||||
readInodeCache <$> readFile (sentinalCacheFile s)
|
||||
readInodeCache <$> readFile (fromRawFilePath (sentinalCacheFile s))
|
||||
gennewcache = genInodeCache (sentinalFile s) noTSDelta
|
||||
calc (InodeCache (InodeCachePrim oldinode oldsize oldmtime)) (InodeCache (InodeCachePrim newinode newsize newmtime)) =
|
||||
SentinalStatus (not unchanged) tsdelta
|
||||
|
@ -281,7 +276,7 @@ checkSentinalFile s = do
|
|||
dummy = SentinalStatus True noTSDelta
|
||||
|
||||
sentinalFileExists :: SentinalFile -> IO Bool
|
||||
sentinalFileExists s = allM doesFileExist [sentinalCacheFile s, sentinalFile s]
|
||||
sentinalFileExists s = allM R.doesPathExist [sentinalCacheFile s, sentinalFile s]
|
||||
|
||||
instance Arbitrary InodeCache where
|
||||
arbitrary =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue