annex.jobs

Added annex.jobs setting, which is like using the -J option.

Of course, -J overrides annex.jobs.

This commit was sponsored by Trenton Cronholm on Patreon.
This commit is contained in:
Joey Hess 2018-10-04 12:47:27 -04:00
parent 585e6b39aa
commit 6ba3dea566
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 46 additions and 17 deletions

View file

@ -3,6 +3,7 @@ git-annex (6.20180927) UNRELEASED; urgency=medium
* sync: Warn when a remote's export is not updated to the current * sync: Warn when a remote's export is not updated to the current
tree because export tracking is not configured. tree because export tracking is not configured.
* Improve display when git config download from a http remote fails. * Improve display when git config download from a http remote fails.
* Added annex.jobs setting, which is like using the -J option.
-- Joey Hess <id@joeyh.name> Thu, 27 Sep 2018 15:27:20 -0400 -- Joey Hess <id@joeyh.name> Thu, 27 Sep 2018 15:27:20 -0400

View file

@ -170,20 +170,32 @@ callCommandActionQuiet = start
{- Do concurrent output when that has been requested. -} {- Do concurrent output when that has been requested. -}
allowConcurrentOutput :: Annex a -> Annex a allowConcurrentOutput :: Annex a -> Annex a
#ifdef WITH_CONCURRENTOUTPUT #ifdef WITH_CONCURRENTOUTPUT
allowConcurrentOutput a = go =<< Annex.getState Annex.concurrency allowConcurrentOutput a = do
fromcmdline <- Annex.getState Annex.concurrency
fromgitcfg <- annexJobs <$> Annex.getGitConfig
case (fromcmdline, fromgitcfg) of
(NonConcurrent, NonConcurrent) -> a
(Concurrent n, _) -> goconcurrent n
(NonConcurrent, Concurrent n) -> do
Annex.changeState $
\c -> c { Annex.concurrency = fromgitcfg }
goconcurrent n
where where
go NonConcurrent = a goconcurrent n = do
go (Concurrent _) = ifM (liftIO concurrentOutputSupported) c <- liftIO getNumCapabilities
( Regions.displayConsoleRegions $ when (n > c) $
goconcurrent True liftIO $ setNumCapabilities n
, goconcurrent False ifM (liftIO concurrentOutputSupported)
) ( Regions.displayConsoleRegions $
goconcurrent b = bracket_ (setup b) cleanup a goconcurrent' True
setup = setconcurrentenabled , goconcurrent' False
)
goconcurrent' b = bracket_ (setup b) cleanup a
setup = setconcurrentoutputenabled
cleanup = do cleanup = do
finishCommandActions finishCommandActions
setconcurrentenabled False setconcurrentoutputenabled False
setconcurrentenabled b = Annex.changeState $ \s -> setconcurrentoutputenabled b = Annex.changeState $ \s ->
s { Annex.output = (Annex.output s) { concurrentOutputEnabled = b } } s { Annex.output = (Annex.output s) { concurrentOutputEnabled = b } }
#else #else
allowConcurrentOutput = id allowConcurrentOutput = id

View file

@ -13,7 +13,6 @@ import Options.Applicative
#if ! MIN_VERSION_optparse_applicative(0,14,1) #if ! MIN_VERSION_optparse_applicative(0,14,1)
import Options.Applicative.Builder.Internal import Options.Applicative.Builder.Internal
#endif #endif
import Control.Concurrent
import qualified Data.Map as M import qualified Data.Map as M
import Annex.Common import Annex.Common
@ -370,11 +369,7 @@ jobsOption =
) )
] ]
where where
set n = do set n = Annex.changeState $ \s -> s { Annex.concurrency = Concurrent n }
Annex.changeState $ \s -> s { Annex.concurrency = Concurrent n }
c <- liftIO getNumCapabilities
when (n > c) $
liftIO $ setNumCapabilities n
timeLimitOption :: [GlobalOption] timeLimitOption :: [GlobalOption]
timeLimitOption = timeLimitOption =

View file

@ -26,6 +26,7 @@ import Config.Cost
import Types.UUID import Types.UUID
import Types.Distribution import Types.Distribution
import Types.Availability import Types.Availability
import Types.Concurrency
import Types.NumCopies import Types.NumCopies
import Types.Difference import Types.Difference
import Types.RefSpec import Types.RefSpec
@ -99,6 +100,7 @@ data GitConfig = GitConfig
, annexAllowedHttpAddresses :: String , annexAllowedHttpAddresses :: String
, annexAllowUnverifiedDownloads :: Bool , annexAllowUnverifiedDownloads :: Bool
, annexMaxExtensionLength :: Maybe Int , annexMaxExtensionLength :: Maybe Int
, annexJobs :: Concurrency
, coreSymlinks :: Bool , coreSymlinks :: Bool
, coreSharedRepository :: SharedRepository , coreSharedRepository :: SharedRepository
, receiveDenyCurrentBranch :: DenyCurrentBranch , receiveDenyCurrentBranch :: DenyCurrentBranch
@ -173,6 +175,7 @@ extractGitConfig r = GitConfig
, annexAllowUnverifiedDownloads = (== Just "ACKTHPPT") $ , annexAllowUnverifiedDownloads = (== Just "ACKTHPPT") $
getmaybe (annex "security.allow-unverified-downloads") getmaybe (annex "security.allow-unverified-downloads")
, annexMaxExtensionLength = getmayberead (annex "maxextensionlength") , annexMaxExtensionLength = getmayberead (annex "maxextensionlength")
, annexJobs = maybe NonConcurrent Concurrent $ getmayberead (annex "jobs")
, coreSymlinks = getbool "core.symlinks" True , coreSymlinks = getbool "core.symlinks" True
, coreSharedRepository = getSharedRepository r , coreSharedRepository = getSharedRepository r
, receiveDenyCurrentBranch = getDenyCurrentBranch r , receiveDenyCurrentBranch = getDenyCurrentBranch r

View file

@ -935,6 +935,13 @@ Here are all the supported configuration settings.
This controls which refs `git-annex unused` considers to be used. This controls which refs `git-annex unused` considers to be used.
See REFSPEC FORMAT in [[git-annex-unused]](1) for details. See REFSPEC FORMAT in [[git-annex-unused]](1) for details.
* `annex.jobs
Configure the number of concurrent jobs to run. Default is 1.
Only git-annex commands that support the --jobs option will
use this.
* `annex.queuesize` * `annex.queuesize`
git-annex builds a queue of git commands, in order to combine similar git-annex builds a queue of git commands, in order to combine similar

View file

@ -0,0 +1,11 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2018-10-04T16:04:57Z"
content="""
git-annex is rarely cpu-bound so I don't know how useful that would really
be in practice.
A git config to set the concurrency level is certianly a good idea,
implemented as annex.jobs.
"""]]