aboutsummaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-06 13:32:47 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-06 13:32:47 -0400
commitac0dcdeeeb9f970419b9cee571e6438bc93b0785 (patch)
treefccef7d2ce120bc57cae1c2cfac4c59a4f41ce88 /Assistant
parentb810f6903b7941f82b180f6399025b4266ee1c57 (diff)
assistant: Add 1/200th second delay between checking each file in the full transfer scan, to avoid using too much CPU.
The slowdown is not going to be large in typical small-ish repos. And it does not seem to matter if the assistant reacts a little bit slower in situations involving the expensive scan, since: a) Those situations typically involve getting back in sync after something has changed on a remote, often after a disconnect of some duration. So taking a few seconds more is not noticable. b) If the scan finds things that it needs to do, it will start blocking anyway after 10 transfers are queued (due to use of queueTransferWhenSmall). So, only the speed of finding the first 10 transfers will be impacted by this change. This commit was sponsored by Jochen Bartl on Patreon.
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/TransferScanner.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs
index a55a3496e..2128ce969 100644
--- a/Assistant/Threads/TransferScanner.hs
+++ b/Assistant/Threads/TransferScanner.hs
@@ -25,6 +25,7 @@ import qualified Types.Remote as Remote
import Utility.ThreadScheduler
import Utility.NotificationBroadcaster
import Utility.Batch
+import Utility.ThreadScheduler
import qualified Git.LsFiles as LsFiles
import Annex.WorkTree
import Annex.Content
@@ -32,6 +33,7 @@ import Annex.Wanted
import CmdLine.Action
import qualified Data.Set as S
+import Control.Concurrent
{- This thread waits until a remote needs to be scanned, to find transfers
- that need to be made, to keep data in sync.
@@ -145,6 +147,10 @@ expensiveScan urlrenderer rs = batch <~> do
(findtransfers f unwanted)
=<< liftAnnex (lookupFile f)
mapM_ (enqueue f) ts
+
+ {- Delay for a short time to avoid using too much CPU. -}
+ liftIO $ threadDelay $ fromIntegral $ oneSecond `div` 200
+
scan unwanted' fs
enqueue f (r, t) =