@@ -743,19 +743,22 @@ getHiddenDiagnostics IdeState{shakeExtras = ShakeExtras{hiddenDiagnostics}} = do
743
743
garbageCollectDirtyKeys :: Action ()
744
744
garbageCollectDirtyKeys = do
745
745
start <- liftIO offsetTime
746
- dirtyKeys <- fromMaybe [] <$> getDirtySet
746
+ dirtySet <- fromMaybe [] <$> getDirtySet
747
747
extras <- getShakeExtras
748
- n <- liftIO $ modifyVar (state extras) $ \ vmap ->
749
- evaluate $ foldl' removeDirtyKey (vmap, 0 ) dirtyKeys
748
+ (n:: Int , garbage ) <- liftIO $ modifyVar (state extras) $ \ vmap ->
749
+ evaluate $ foldl' removeDirtyKey (vmap, (0 ,[] )) dirtySet
750
+ liftIO $ atomicModifyIORef_ (dirtyKeys extras) $ \ x ->
751
+ foldl' (flip HSet. insert) x garbage
750
752
t <- liftIO start
751
- liftIO $ logDebug (logger extras) $ T. pack $
753
+ when (n > 0 ) $ liftIO $ logDebug (logger extras) $ T. pack $
752
754
" Garbage collected " <> show n <> " keys (took " <> showDuration t <> " )"
753
755
where
754
- removeDirtyKey :: (Values , Int ) -> (Key , Int ) -> (Values , Int )
755
- removeDirtyKey (vmap,counter) (k, age)
756
+ -- removeDirtyKey :: (Values, Int) -> (Key, Int) -> (Values, [Key] , Int)
757
+ removeDirtyKey (vmap,( counter, keys) ) (k, age)
756
758
| age > garbageAge
757
- = let ! c' = counter + 1 in (HMap. delete k vmap, c')
758
- | otherwise = (vmap,counter)
759
+ , (True , vmap') <- HMap. alterF (\ prev -> (isJust prev, Nothing )) k vmap
760
+ = let ! c' = counter+ 1 in (vmap', (c', k: keys))
761
+ | otherwise = (vmap, (counter, keys))
759
762
760
763
-- | Define a new Rule without early cutoff
761
764
define
0 commit comments