From d4ee2d7345b03917bbf543a42c245d379dba0d5a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 8 Mar 2017 14:49:30 -0400 Subject: get -J: Improve distribution of jobs amoung remotes when there are more jobs than remotes. It was distributing jobs to remotes that were not being used by any other job. But, suppose that there are only 2 remotes, and -J10. In such a case, the first 2 downloads would be distributed amoung the 2 remotes, but the other 8 would all go to remote #1. Improved by keeping a counter of how many jobs are assigned to a remote, and prefer remotes with fewer jobs. Note use of Data.Map.Strict to avoid blowing up space. I kept the bang-patterns as-is, although probably not needed with Data.Map.Strict. This commit was sponsored by Jack Hill on Patreon. --- Annex.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Annex.hs') diff --git a/Annex.hs b/Annex.hs index 1ee6e837f..95709faec 100644 --- a/Annex.hs +++ b/Annex.hs @@ -136,7 +136,7 @@ data AnnexState = AnnexState , existinghooks :: M.Map Git.Hook.Hook Bool , desktopnotify :: DesktopNotify , workers :: [Either AnnexState (Async AnnexState)] - , activeremotes :: MVar (S.Set (Types.Remote.RemoteA Annex)) + , activeremotes :: MVar (M.Map (Types.Remote.RemoteA Annex) Integer) , keysdbhandle :: Maybe Keys.DbHandle , cachedcurrentbranch :: Maybe Git.Branch , cachedgitenv :: Maybe [(String, String)] @@ -144,7 +144,7 @@ data AnnexState = AnnexState newState :: GitConfig -> Git.Repo -> IO AnnexState newState c r = do - emptyactiveremotes <- newMVar S.empty + emptyactiveremotes <- newMVar M.empty return $ AnnexState { repo = r , repoadjustment = return -- cgit v1.2.3