Skip to content

Commit 0a42e47

Browse files
committed
remove garbage collection of not visited keys
The "visited age" metric is not accurate in hls-graph because of reverse-dependencies-guided work avoidance
1 parent 8e83363 commit 0a42e47

File tree

5 files changed

+9
-34
lines changed

5 files changed

+9
-34
lines changed

ghcide/src/Development/IDE/Core/OfInterest.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ kick = do
111111

112112
liftIO $ progressUpdate progress KickCompleted
113113

114-
-- if idle, perform garbage collection
114+
-- if idle, perform garbage collection of dirty keys
115115
liftIO $ sleep 5
116116
void garbageCollectDirtyKeys
117-
118-
-- if still idle, collect unpopular keys
119-
void garbageCollectKeysNotVisited

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ module Development.IDE.Core.Shake(
7676
addPersistentRule,
7777
garbageCollectDirtyKeys,
7878
garbageCollectDirtyKeysOlderThan,
79-
garbageCollectKeysNotVisited,
80-
garbageCollectKeysNotVisitedFor
8179
) where
8280

8381
import Control.Concurrent.Async
@@ -767,22 +765,11 @@ garbageCollectDirtyKeys = do
767765
checkParents <- liftIO optCheckParents
768766
garbageCollectDirtyKeysOlderThan optMaxDirtyAge checkParents
769767

770-
garbageCollectKeysNotVisited :: Action [Key]
771-
garbageCollectKeysNotVisited = do
772-
IdeOptions{optCheckParents, optMaxDirtyAge} <- getIdeOptions
773-
checkParents <- liftIO optCheckParents
774-
garbageCollectKeysNotVisitedFor optMaxDirtyAge checkParents
775-
776768
garbageCollectDirtyKeysOlderThan :: Int -> CheckParents -> Action [Key]
777769
garbageCollectDirtyKeysOlderThan maxAge checkParents = otTracedGarbageCollection "dirty GC" $ do
778770
dirtySet <- fromMaybe [] <$> getDirtySet
779771
garbageCollectKeys "dirty GC" maxAge checkParents dirtySet
780772

781-
garbageCollectKeysNotVisitedFor :: Int -> CheckParents -> Action [Key]
782-
garbageCollectKeysNotVisitedFor maxAge checkParents = otTracedGarbageCollection "not visited GC" $ do
783-
keys <- getKeysAndVisitedAge
784-
garbageCollectKeys "not visited GC" maxAge checkParents keys
785-
786773
garbageCollectKeys :: String -> Int -> CheckParents -> [(Key, Int)] -> Action [Key]
787774
garbageCollectKeys label maxAge checkParents agedKeys = do
788775
start <- liftIO offsetTime

ghcide/src/Development/IDE/Plugin/Test.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ data TestRequest
4848
| WaitForShakeQueue -- ^ Block until the Shake queue is empty. Returns Null
4949
| WaitForIdeRule String Uri -- ^ :: WaitForIdeRuleResult
5050
| GarbageCollectDirtyKeys CheckParents Age -- ^ :: [String] (list of keys collected)
51-
| GarbageCollectNotVisitedKeys CheckParents Age -- ^ :: [String]
5251
| GetStoredKeys -- ^ :: [String] (list of keys in store)
5352
| GetFilesOfInterest -- ^ :: [FilePath]
5453
deriving Generic
@@ -100,9 +99,6 @@ testRequestHandler s (WaitForIdeRule k file) = liftIO $ do
10099
testRequestHandler s (GarbageCollectDirtyKeys parents age) = do
101100
res <- liftIO $ runAction "garbage collect dirty" s $ garbageCollectDirtyKeysOlderThan age parents
102101
return $ Right $ toJSON $ map show res
103-
testRequestHandler s (GarbageCollectNotVisitedKeys parents age) = do
104-
res <- liftIO $ runAction "garbage collect not visited" s $ garbageCollectKeysNotVisitedFor age parents
105-
return $ Right $ toJSON $ map show res
106102
testRequestHandler s GetStoredKeys = do
107103
keys <- liftIO $ HM.keys <$> readVar (state $ shakeExtras s)
108104
return $ Right $ toJSON $ map show keys

ghcide/test/exe/Main.hs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ import Development.IDE.Test (Cursor,
5555
getStoredKeys,
5656
waitForTypecheck,
5757
getFilesOfInterest,
58-
waitForBuildQueue,
59-
garbageCollectNotVisitedKeys)
58+
waitForBuildQueue)
6059
import Development.IDE.Test.Runfiles
6160
import qualified Development.IDE.Types.Diagnostics as Diagnostics
6261
import Development.IDE.Types.Location
@@ -5847,7 +5846,6 @@ unitTests = do
58475846
garbageCollectionTests :: TestTree
58485847
garbageCollectionTests = testGroup "garbage collection"
58495848
[ testGroup "dirty keys" (sharedGCtests $ garbageCollectDirtyKeys CheckOnSaveAndClose)
5850-
, testGroup "unvisited keys" (sharedGCtests $ garbageCollectNotVisitedKeys CheckOnSaveAndClose)
58515849
]
58525850
where
58535851
sharedGCtests gc =
@@ -5870,19 +5868,19 @@ garbageCollectionTests = testGroup "garbage collection"
58705868
liftIO $ writeFile (dir </> "hie.yaml") "cradle: {direct: {arguments: [A.hs, B.hs]}}"
58715869
void $ generateGarbage "A" dir
58725870

5873-
keysA <- getStoredKeys
5874-
58755871
reopenB <- generateGarbage "B" dir
58765872
-- garbage collect A keys
5877-
garbage <- gc 1
5873+
keysBeforeGC <- getStoredKeys
5874+
garbage <- gc 2
58785875
liftIO $ assertBool "something is wrong with this test - no garbage found" $ not $ null garbage
5879-
keysB <- getStoredKeys
5880-
liftIO $ assertBool "something is wrong with this test - keys were not deleted from the state" (length keysB < length keysA)
5876+
keysAfterGC <- getStoredKeys
5877+
liftIO $ assertBool "something is wrong with this test - keys were not deleted from the state" (length keysAfterGC < length keysBeforeGC)
58815878
ff <- getFilesOfInterest
58825879
liftIO $ assertBool ("something is wrong with this test - files of interest is " <> show ff) (null ff)
58835880

58845881
-- typecheck B again
5885-
_ <- reopenB
5882+
doc <- reopenB
5883+
void $ waitForTypecheck doc
58865884

58875885
-- review the keys in store now to validate that A keys have not been regenerated
58885886
keysB' <- getStoredKeys
@@ -5922,6 +5920,7 @@ garbageCollectionTests = testGroup "garbage collection"
59225920
-- dirty the garbage
59235921
sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
59245922
List [FileEvent (filePathToUri $ dir </> modName <> ".hs") FcChanged ]
5923+
59255924
return $ openDoc (modName <> ".hs") "haskell"
59265925

59275926
findResolution_us :: Int -> IO Int

ghcide/test/src/Development/IDE/Test.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module Development.IDE.Test
2525
, waitForTypecheck
2626
, waitForBuildQueue
2727
, getStoredKeys
28-
, garbageCollectNotVisitedKeys
2928
) where
3029

3130
import Control.Applicative.Combinators
@@ -194,9 +193,6 @@ waitForAction key TextDocumentIdentifier{_uri} = callTestPlugin (WaitForIdeRule
194193
garbageCollectDirtyKeys :: CheckParents -> Int -> Session [String]
195194
garbageCollectDirtyKeys parents age = callTestPlugin (GarbageCollectDirtyKeys parents age)
196195

197-
garbageCollectNotVisitedKeys :: CheckParents -> Int -> Session [String]
198-
garbageCollectNotVisitedKeys parents age = callTestPlugin (GarbageCollectNotVisitedKeys parents age)
199-
200196
getStoredKeys :: Session [String]
201197
getStoredKeys = callTestPlugin GetStoredKeys
202198

0 commit comments

Comments
 (0)