make WorkerStage an open type
Rather than limiting it to PerformStage and CleanupStage, this opens it up so any number of stages can be added as needed by commands. Each concurrent command has a set of stages that it uses, and only transitions between those can block waiting for a free slot in the worker pool. Calling enteringStage for some other stage does not block, and has very little overhead. Note that while before the Annex state was duplicated on the first call to commandAction, this now happens earlier, in startConcurrency. That means that seek stage actions should that use startConcurrency and then modify Annex state won't modify the state of worker threads they then start. I audited all of them, and only Command.Seek did so; prepMerge changes the working directory and so has to come before startConcurrency. Also, the remote list is built before duplicating the state, which means that it gets built earlier now than it used to. This would only have an effect of making commands that end up not needing to perform any actions unncessary build the remote list (only when they're run with concurrency enable), but that's a minor overhead compared to commands seeking through the work tree and determining they don't need to do anything.
This commit is contained in:
parent
e19408ed9d
commit
53882ab4a7
17 changed files with 230 additions and 147 deletions
|
@ -50,7 +50,7 @@ optParser desc = AddOptions
|
|||
)
|
||||
|
||||
seek :: AddOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = startConcurrency commandStages $ do
|
||||
matcher <- largeFilesMatcher
|
||||
let gofile file = ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force)
|
||||
( start file
|
||||
|
|
|
@ -93,7 +93,7 @@ parseDownloadOptions withfileoption = DownloadOptions
|
|||
else pure Nothing
|
||||
|
||||
seek :: AddUrlOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = startConcurrency commandStages $ do
|
||||
forM_ (addUrls o) (\u -> go (o, u))
|
||||
case batchOption o of
|
||||
Batch fmt -> batchInput fmt (parseBatchInput o) go
|
||||
|
|
|
@ -44,7 +44,7 @@ instance DeferredParseClass CopyOptions where
|
|||
<*> pure (batchOption v)
|
||||
|
||||
seek :: CopyOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = startConcurrency commandStages $ do
|
||||
let go = whenAnnexed $ start o
|
||||
case batchOption o of
|
||||
Batch fmt -> batchFilesMatching fmt go
|
||||
|
|
|
@ -52,7 +52,7 @@ parseDropFromOption = parseRemoteOption <$> strOption
|
|||
)
|
||||
|
||||
seek :: DropOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $
|
||||
seek o = startConcurrency commandStages $
|
||||
case batchOption o of
|
||||
Batch fmt -> batchFilesMatching fmt go
|
||||
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
|
||||
|
|
|
@ -88,7 +88,7 @@ optParser desc = FsckOptions
|
|||
))
|
||||
|
||||
seek :: FsckOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = startConcurrency commandStages $ do
|
||||
from <- maybe (pure Nothing) (Just <$$> getParsed) (fsckFromOption o)
|
||||
u <- maybe getUUID (pure . Remote.uuid) from
|
||||
checkDeadRepo u
|
||||
|
|
|
@ -38,7 +38,7 @@ optParser desc = GetOptions
|
|||
<*> parseBatchOption
|
||||
|
||||
seek :: GetOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = startConcurrency commandStages $ do
|
||||
from <- maybe (pure Nothing) (Just <$$> getParsed) (getFrom o)
|
||||
let go = whenAnnexed $ start o from
|
||||
case batchOption o of
|
||||
|
|
|
@ -96,7 +96,7 @@ duplicateModeParser =
|
|||
)
|
||||
|
||||
seek :: ImportOptions -> CommandSeek
|
||||
seek o@(LocalImportOptions {}) = allowConcurrentOutput $ do
|
||||
seek o@(LocalImportOptions {}) = startConcurrency commandStages $ do
|
||||
repopath <- liftIO . absPath =<< fromRepo Git.repoPath
|
||||
inrepops <- liftIO $ filter (dirContains repopath) <$> mapM absPath (importFiles o)
|
||||
unless (null inrepops) $ do
|
||||
|
@ -104,7 +104,7 @@ seek o@(LocalImportOptions {}) = allowConcurrentOutput $ do
|
|||
largematcher <- largeFilesMatcher
|
||||
(commandAction . startLocal largematcher (duplicateMode o))
|
||||
`withPathContents` importFiles o
|
||||
seek o@(RemoteImportOptions {}) = allowConcurrentOutput $ do
|
||||
seek o@(RemoteImportOptions {}) = startConcurrency commandStages $ do
|
||||
r <- getParsed (importFromRemote o)
|
||||
unlessM (Remote.isImportSupported r) $
|
||||
giveup "That remote does not support imports."
|
||||
|
|
|
@ -41,7 +41,7 @@ instance DeferredParseClass MirrorOptions where
|
|||
<*> pure (keyOptions v)
|
||||
|
||||
seek :: MirrorOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $
|
||||
seek o = startConcurrency commandStages $
|
||||
withKeyOptions (keyOptions o) False
|
||||
(commandAction . startKey o (AssociatedFile Nothing))
|
||||
(withFilesInGit (commandAction . (whenAnnexed $ start o)))
|
||||
|
|
|
@ -54,7 +54,7 @@ data RemoveWhen = RemoveSafe | RemoveNever
|
|||
deriving (Show, Eq)
|
||||
|
||||
seek :: MoveOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = startConcurrency commandStages $ do
|
||||
let go = whenAnnexed $ start (fromToOptions o) (removeWhen o)
|
||||
case batchOption o of
|
||||
Batch fmt -> batchFilesMatching fmt go
|
||||
|
|
|
@ -162,9 +162,12 @@ instance DeferredParseClass SyncOptions where
|
|||
<*> pure (resolveMergeOverride v)
|
||||
|
||||
seek :: SyncOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
seek o = do
|
||||
prepMerge
|
||||
|
||||
startConcurrency commandStages (seek' o)
|
||||
|
||||
seek' :: SyncOptions -> CommandSeek
|
||||
seek' o = do
|
||||
let withbranch a = a =<< getCurrentBranch
|
||||
|
||||
remotes <- syncRemotes (syncWith o)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue