suggest when user may want annex.stalldetection
When annex.stalldetection is not enabled, and a likely stall is detected, display a suggestion to enable it. Note that the progress meter display is not taken down when displaying the message, so it will display like this: 0% 8 B 0 B/s Transfer seems to have stalled. To handle stalling transfers, configure annex.stalldetection 0% 10 B 0 B/s Although of course if it's really stalled, it will never update again after the message. Taking down the progress meter and starting a new one doesn't seem too necessary given how unusual this is, also this does help show the state it was at when it stalled. Use of uninterruptibleCancel here is ok, the thread it's canceling only does STM transactions and sleeps. The annex thread that gets forked off is separate to avoid it being canceled, so that it can be joined back at the end. A module cycle required moving from dupState the precaching of the remote list. Doing it at startConcurrency should cover all the cases where the remote list is used in concurrent actions. This commit was sponsored by Kevin Mueller on Patreon.
This commit is contained in:
parent
7db4e62a90
commit
dd39e9e255
18 changed files with 160 additions and 101 deletions
|
@ -15,9 +15,13 @@ import Utility.DataUnits
|
|||
import Utility.ThreadScheduler
|
||||
|
||||
import Control.Concurrent.STM
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
|
||||
detectStalls :: Maybe StallDetection -> TVar (Maybe BytesProcessed) -> IO () -> IO ()
|
||||
{- This may be safely canceled (with eg uninterruptibleCancel),
|
||||
- as long as the passed action can be safely canceled. -}
|
||||
detectStalls :: (Monad m, MonadIO m) => Maybe StallDetection -> TVar (Maybe BytesProcessed) -> m () -> m ()
|
||||
detectStalls Nothing _ _ = noop
|
||||
detectStalls (Just StallDetectionDisabled) _ _ = noop
|
||||
detectStalls (Just (StallDetection minsz duration)) metervar onstall =
|
||||
detectStalls' minsz duration metervar onstall Nothing
|
||||
detectStalls (Just ProbeStallDetection) metervar onstall = do
|
||||
|
@ -30,7 +34,7 @@ detectStalls (Just ProbeStallDetection) metervar onstall = do
|
|||
ontimelyadvance v $ \v' -> ontimelyadvance v' $
|
||||
detectStalls' 1 duration metervar onstall
|
||||
where
|
||||
getval = atomically $ fmap fromBytesProcessed
|
||||
getval = liftIO $ atomically $ fmap fromBytesProcessed
|
||||
<$> readTVar metervar
|
||||
|
||||
duration = Duration 60
|
||||
|
@ -38,29 +42,30 @@ detectStalls (Just ProbeStallDetection) metervar onstall = do
|
|||
delay = Seconds (fromIntegral (durationSeconds duration) `div` 2)
|
||||
|
||||
waitforfirstupdate startval = do
|
||||
threadDelaySeconds delay
|
||||
liftIO $ threadDelaySeconds delay
|
||||
v <- getval
|
||||
if v > startval
|
||||
then return v
|
||||
else waitforfirstupdate startval
|
||||
|
||||
ontimelyadvance v cont = do
|
||||
threadDelaySeconds delay
|
||||
liftIO $ threadDelaySeconds delay
|
||||
v' <- getval
|
||||
when (v' > v) $
|
||||
cont v'
|
||||
|
||||
detectStalls'
|
||||
:: ByteSize
|
||||
:: (Monad m, MonadIO m)
|
||||
=> ByteSize
|
||||
-> Duration
|
||||
-> TVar (Maybe BytesProcessed)
|
||||
-> IO ()
|
||||
-> m ()
|
||||
-> Maybe ByteSize
|
||||
-> IO ()
|
||||
-> m ()
|
||||
detectStalls' minsz duration metervar onstall st = do
|
||||
threadDelaySeconds delay
|
||||
liftIO $ threadDelaySeconds delay
|
||||
-- Get whatever progress value was reported most recently, if any.
|
||||
v <- atomically $ fmap fromBytesProcessed
|
||||
v <- liftIO $ atomically $ fmap fromBytesProcessed
|
||||
<$> readTVar metervar
|
||||
let cont = detectStalls' minsz duration metervar onstall v
|
||||
case (st, v) of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue