Skip to content

Commit 463c47a

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 eba4763 commit 463c47a

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 <- 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
@@ -50,7 +50,6 @@ data TestRequest
5050
| WaitForIdeRule String Uri -- ^ :: WaitForIdeRuleResult
5151
| GetLastBuildKeys -- ^ :: [String]
5252
| GarbageCollectDirtyKeys CheckParents Age -- ^ :: [String] (list of keys collected)
53-
| GarbageCollectNotVisitedKeys CheckParents Age -- ^ :: [String]
5453
| GetStoredKeys -- ^ :: [String] (list of keys in store)
5554
| GetFilesOfInterest -- ^ :: [FilePath]
5655
deriving Generic
@@ -105,9 +104,6 @@ testRequestHandler s GetLastBuildKeys = liftIO $ do
105104
testRequestHandler s (GarbageCollectDirtyKeys parents age) = do
106105
res <- liftIO $ runAction "garbage collect dirty" s $ garbageCollectDirtyKeysOlderThan age parents
107106
return $ Right $ toJSON $ map show res
108-
testRequestHandler s (GarbageCollectNotVisitedKeys parents age) = do
109-
res <- liftIO $ runAction "garbage collect not visited" s $ garbageCollectKeysNotVisitedFor age parents
110-
return $ Right $ toJSON $ map show res
111107
testRequestHandler s GetStoredKeys = do
112108
keys <- liftIO $ HM.keys <$> readVar (state $ shakeExtras s)
113109
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
@@ -56,8 +56,7 @@ import Development.IDE.Test (Cursor,
5656
getStoredKeys,
5757
waitForTypecheck,
5858
getFilesOfInterest,
59-
waitForBuildQueue,
60-
garbageCollectNotVisitedKeys)
59+
waitForBuildQueue)
6160
import Development.IDE.Test.Runfiles
6261
import qualified Development.IDE.Types.Diagnostics as Diagnostics
6362
import Development.IDE.Types.Location
@@ -5843,7 +5842,6 @@ unitTests = do
58435842
garbageCollectionTests :: TestTree
58445843
garbageCollectionTests = testGroup "garbage collection"
58455844
[ testGroup "dirty keys" (sharedGCtests $ garbageCollectDirtyKeys CheckOnSaveAndClose)
5846-
, testGroup "unvisited keys" (sharedGCtests $ garbageCollectNotVisitedKeys CheckOnSaveAndClose)
58475845
]
58485846
where
58495847
sharedGCtests gc =
@@ -5866,19 +5864,19 @@ garbageCollectionTests = testGroup "garbage collection"
58665864
liftIO $ writeFile (dir </> "hie.yaml") "cradle: {direct: {arguments: [A.hs, B.hs]}}"
58675865
void $ generateGarbage "A" dir
58685866

5869-
keysA <- getStoredKeys
5870-
58715867
reopenB <- generateGarbage "B" dir
58725868
-- garbage collect A keys
5873-
garbage <- gc 1
5869+
keysBeforeGC <- getStoredKeys
5870+
garbage <- gc 2
58745871
liftIO $ assertBool "something is wrong with this test - no garbage found" $ not $ null garbage
5875-
keysB <- getStoredKeys
5876-
liftIO $ assertBool "something is wrong with this test - keys were not deleted from the state" (length keysB < length keysA)
5872+
keysAfterGC <- getStoredKeys
5873+
liftIO $ assertBool "something is wrong with this test - keys were not deleted from the state" (length keysAfterGC < length keysBeforeGC)
58775874
ff <- getFilesOfInterest
58785875
liftIO $ assertBool ("something is wrong with this test - files of interest is " <> show ff) (null ff)
58795876

58805877
-- typecheck B again
5881-
_ <- reopenB
5878+
doc <- reopenB
5879+
void $ waitForTypecheck doc
58825880

58835881
-- review the keys in store now to validate that A keys have not been regenerated
58845882
keysB' <- getStoredKeys
@@ -5918,6 +5916,7 @@ garbageCollectionTests = testGroup "garbage collection"
59185916
-- dirty the garbage
59195917
sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
59205918
List [FileEvent (filePathToUri $ dir </> modName <> ".hs") FcChanged ]
5919+
59215920
return $ openDoc (modName <> ".hs") "haskell"
59225921

59235922
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
@@ -27,7 +27,6 @@ module Development.IDE.Test
2727
, waitForTypecheck
2828
, waitForBuildQueue
2929
, getStoredKeys
30-
, garbageCollectNotVisitedKeys
3130
) where
3231

3332
import Control.Applicative.Combinators
@@ -203,9 +202,6 @@ getInterfaceFilesDir TextDocumentIdentifier{_uri} = callTestPlugin (GetInterface
203202
garbageCollectDirtyKeys :: CheckParents -> Int -> Session [String]
204203
garbageCollectDirtyKeys parents age = callTestPlugin (GarbageCollectDirtyKeys parents age)
205204

206-
garbageCollectNotVisitedKeys :: CheckParents -> Int -> Session [String]
207-
garbageCollectNotVisitedKeys parents age = callTestPlugin (GarbageCollectNotVisitedKeys parents age)
208-
209205
getStoredKeys :: Session [String]
210206
getStoredKeys = callTestPlugin GetStoredKeys
211207

0 commit comments

Comments
 (0)