| bwlimit <= 0 = return meterupdate
| otherwise = do
nowtime <- getPOSIXTime
- mv <- newMVar (nowtime, 0)
+ mv <- newMVar (nowtime, Nothing)
return (mu mv)
where
mu mv n@(BytesProcessed i) = do
endtime <- getPOSIXTime
- (starttime, previ) <- takeMVar mv
-
- let runtime = endtime - starttime
- let currbw = fromIntegral (i - previ) / runtime
- let pausescale = if currbw > bwlimit'
- then (currbw / bwlimit') - 1
- else 0
- unboundDelay (floor (runtime * pausescale * msecs))
+ (starttime, mprevi) <- takeMVar mv
+
+ case mprevi of
+ Just previ -> do
+ let runtime = endtime - starttime
+ let currbw = fromIntegral (i - previ) / runtime
+ let pausescale = if currbw > bwlimit'
+ then (currbw / bwlimit') - 1
+ else 0
+ unboundDelay (floor (runtime * pausescale * msecs))
+ Nothing -> return ()
+
meterupdate n
nowtime <- getPOSIXTime
- putMVar mv (nowtime, i)
+ putMVar mv (nowtime, Just i)
bwlimit' = fromIntegral (bwlimit * durationSeconds duration)
msecs = fromIntegral oneSecond
[[confirmed]]
-> Implemented and works well.
->
-> A local git remote, when resuming an interrupted
+> Implemented and works well. [[done]] --[[Joey]]
+
+> Note: A local git remote, when resuming an interrupted
> transfer, has to hash the file (with default annex.verify settings),
> and that hashing updates the progress bar, and so the bwlimit can kick
> in and slow down that initial hashing, before any data copying begins.
> remote you're wanting to limit disk IO. Only reason it might not be ok
> is if the intent is to limit IO to the disk containing the remote
> but not the one containing the annex repo. (This also probably
-> holds for the directory special remote.)
->
+> holds for the directory special remote.)
> Other remotes, including git over ssh, when resuming don't have that
> problem. Looks like chunked special remotes narrowly avoid it, just
> because their implementation choose to not do incremental verification
> tend to be 32kb or so, and the pauses a small fraction of a second. So
> mentioning this only for completeness.) --[[Joey]]
-[[done]]
-