add restage log
When pointer files need to be restaged, they're first written to the log, and then when the restage operation runs, it reads the log. This way, if the git-annex process is interrupted before it can do the restaging, a later git-annex process can do it. Currently, this lets a git-annex get/drop command be interrupted and then re-ran, and as long as it gets/drops additional files, it will clean up after the interrupted command. But more changes are needed to make it easier to restage after an interrupted process. Kept using the git queue to run the restage action, even though the list of files that it builds up for that action is not actually used by the action. This could perhaps be simplified to make restaging a cleanup action that gets registered, rather than using the git queue for it. But I wasn't sure if that would cause visible behavior changes, when eg dropping a large number of files, currently the git queue flushes periodically, and so it restages incrementally, rather than all at the end. In restagePointerFiles, it reads the restage log twice, once to get the number of files and size, and a second time to process it. This seemed better than reading the whole file into memory, since potentially a huge number of files could be in there. Probably the OS will cache the file in memory and there will not be much performance impact. It might be better to keep running tallies in another file though. But updating that atomically with the log seems hard. Also note that it's possible for calcRestageLog to see a different file than streamRestageLog does. More files may be added to the log in between. That is ok, it will only cause the filterprocessfaster heuristic to operate with slightly out of date information, so it may make the wrong choice for the files that got added and be a little slower than ideal. Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
parent
9c76e503cf
commit
6a3bd283b8
9 changed files with 148 additions and 71 deletions
|
@ -135,8 +135,13 @@ stageDiffTreeItem d = case toTreeItemType (Diff.dstmode d) of
|
|||
indexPath :: TopFilePath -> InternalGitPath
|
||||
indexPath = toInternalGitPath . getTopFilePath
|
||||
|
||||
{- Refreshes the index, by checking file stat information. -}
|
||||
refreshIndex :: (MonadIO m, MonadMask m) => Repo -> ((RawFilePath -> IO ()) -> m ()) -> m Bool
|
||||
{- Refreshes the index, by checking file stat information.
|
||||
-
|
||||
- The action is passed a callback that it can use to send filenames to
|
||||
- update-index. Sending Nothing will wait for update-index to finish
|
||||
- updating the index.
|
||||
-}
|
||||
refreshIndex :: (MonadIO m, MonadMask m) => Repo -> ((Maybe RawFilePath -> IO ()) -> m ()) -> m ()
|
||||
refreshIndex repo feeder = bracket
|
||||
(liftIO $ createProcess p)
|
||||
(liftIO . cleanupProcess)
|
||||
|
@ -154,9 +159,12 @@ refreshIndex repo feeder = bracket
|
|||
{ std_in = CreatePipe }
|
||||
|
||||
go (Just h, _, _, pid) = do
|
||||
feeder $ \f ->
|
||||
S.hPut h (S.snoc f 0)
|
||||
liftIO $ hFlush h
|
||||
liftIO $ hClose h
|
||||
liftIO $ checkSuccessProcess pid
|
||||
let closer = do
|
||||
hFlush h
|
||||
hClose h
|
||||
forceSuccessProcess p pid
|
||||
feeder $ \case
|
||||
Just f -> S.hPut h (S.snoc f 0)
|
||||
Nothing -> closer
|
||||
liftIO $ closer
|
||||
go _ = error "internal"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue