Skip to content

Commit 6e90a55

Browse files
committed
update hls-graph runtime
1 parent 26aa9be commit 6e90a55

File tree

22 files changed

+716
-655
lines changed

22 files changed

+716
-655
lines changed

ghcide/ghcide.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ library
142142
Development.IDE.Core.Shake
143143
Development.IDE.Core.Tracing
144144
Development.IDE.Core.UseStale
145-
Development.IDE.Core.WorkerThread
146145
Development.IDE.GHC.Compat
147146
Development.IDE.GHC.Compat.Core
148147
Development.IDE.GHC.Compat.CmdLine

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ import Data.Void
8181

8282
import Control.Concurrent.STM.Stats (atomically, modifyTVar',
8383
readTVar, writeTVar)
84-
import Control.Concurrent.STM.TQueue
8584
import Control.Monad.Trans.Cont (ContT (ContT, runContT))
8685
import Data.Foldable (for_)
8786
import Data.HashMap.Strict (HashMap)
8887
import Data.HashSet (HashSet)
8988
import qualified Data.HashSet as Set
9089
import Database.SQLite.Simple
9190
import Development.IDE.Core.Tracing (withTrace)
92-
import Development.IDE.Core.WorkerThread (withWorkerQueue)
9391
import Development.IDE.Session.Dependency
9492
import Development.IDE.Session.Diagnostics (renderCradleError)
9593
import Development.IDE.Session.Ghc hiding (Log)
@@ -108,6 +106,7 @@ import qualified Control.Monad.STM as STM
108106
import Control.Monad.Trans.Reader
109107
import qualified Development.IDE.Session.Ghc as Ghc
110108
import qualified Development.IDE.Session.OrderedSet as S
109+
import Development.IDE.WorkerThread
111110
import qualified Focus
112111
import qualified StmContainers.Map as STM
113112

@@ -133,10 +132,13 @@ data Log
133132
| LogLookupSessionCache !FilePath
134133
| LogTime !String
135134
| LogSessionGhc Ghc.Log
135+
| LogSessionWorkerThread LogWorkerThread
136136
deriving instance Show Log
137137

138+
138139
instance Pretty Log where
139140
pretty = \case
141+
LogSessionWorkerThread lt -> pretty lt
140142
LogTime s -> "Time:" <+> pretty s
141143
LogLookupSessionCache path -> "Looking up session cache for" <+> pretty path
142144
LogGetOptionsLoop fp -> "Loop: getOptions for" <+> pretty fp
@@ -362,7 +364,7 @@ runWithDb recorder fp = ContT $ \k -> do
362364
_ <- withWriteDbRetryable deleteMissingRealFiles
363365
_ <- withWriteDbRetryable garbageCollectTypeNames
364366

365-
runContT (withWorkerQueue (writer withWriteDbRetryable)) $ \chan ->
367+
runContT (withWorkerQueue (logWith (cmapWithPrio LogSessionWorkerThread recorder) Debug) "hiedb thread" (writer withWriteDbRetryable)) $ \chan ->
366368
withHieDb fp (\readDb -> k (WithHieDbShield $ makeWithHieDbRetryable recorder rng readDb, chan))
367369
where
368370
writer withHieDbRetryable l = do
@@ -589,7 +591,7 @@ newSessionState = do
589591
-- components mapping to the same hie.yaml file are mapped to the same
590592
-- HscEnv which is updated as new components are discovered.
591593

592-
loadSessionWithOptions :: Recorder (WithPriority Log) -> SessionLoadingOptions -> FilePath -> TQueue (IO ()) -> IO (Action IdeGhcSession)
594+
loadSessionWithOptions :: Recorder (WithPriority Log) -> SessionLoadingOptions -> FilePath -> TaskQueue (IO ()) -> IO (Action IdeGhcSession)
593595
loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
594596
let toAbsolutePath = toAbsolute rootDir -- see Note [Root Directory]
595597

@@ -617,7 +619,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
617619

618620
-- see Note [Serializing runs in separate thread]
619621
-- Start the getOptionsLoop if the queue is empty
620-
liftIO $ atomically $ Extra.whenM (isEmptyTQueue que) $ do
622+
liftIO $ atomically $ Extra.whenM (isEmptyTaskQueue que) $ do
621623
let newSessionLoadingOptions = SessionLoadingOptions
622624
{ findCradle = cradleLoc
623625
, ..
@@ -636,7 +638,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
636638
, sessionLoadingOptions = newSessionLoadingOptions
637639
}
638640

639-
writeTQueue que (runReaderT (getOptionsLoop recorder sessionShake sessionState knownTargetsVar) sessionEnv)
641+
writeTaskQueue que (runReaderT (getOptionsLoop recorder sessionShake sessionState knownTargetsVar) sessionEnv)
640642

641643
-- Each one of deps will be registered as a FileSystemWatcher in the GhcSession action
642644
-- so that we can get a workspace/didChangeWatchedFiles notification when a dep changes.
@@ -935,7 +937,7 @@ loadCradleWithNotifications recorder sessionState loadCradle hieYaml cfp = do
935937
when (isNothing hieYaml) $
936938
logWith recorder Warning $ LogCradleNotFound lfpLog
937939
cradle <- liftIO $ loadCradle hieYaml rootDir
938-
when (isTesting) $ mRunLspT lspEnv $
940+
when isTesting $ mRunLspT lspEnv $
939941
sendNotification (SMethod_CustomMethod (Proxy @"ghcide/cradle/loaded")) (toJSON cfp)
940942

941943
-- Display a user friendly progress message here: They probably don't know what a cradle is
@@ -1034,7 +1036,7 @@ data PackageSetupException
10341036
{ compileTime :: !Version
10351037
, runTime :: !Version
10361038
}
1037-
deriving (Eq, Show, Typeable)
1039+
deriving (Eq, Show)
10381040

10391041
instance Exception PackageSetupException
10401042

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ import qualified GHC.Runtime.Loader as Loader
114114
import GHC.Tc.Gen.Splice
115115
import GHC.Types.Error
116116
import GHC.Types.ForeignStubs
117-
import GHC.Types.HpcInfo
118117
import GHC.Types.TypeEnv
119118

120119
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
@@ -151,6 +150,7 @@ import GHC.Iface.Ext.Types (NameEntityInfo)
151150

152151
#if MIN_VERSION_ghc(9,12,0)
153152
import Development.IDE.Import.FindImports
153+
import Development.IDE.WorkerThread (writeTaskQueue)
154154
#endif
155155

156156
--Simple constants to make sure the source is consistently named
@@ -883,7 +883,7 @@ indexHieFile se mod_summary srcPath !hash hf = do
883883
-- hiedb doesn't use the Haskell src, so we clear it to avoid unnecessarily keeping it around
884884
let !hf' = hf{hie_hs_src = mempty}
885885
modifyTVar' indexPending $ HashMap.insert srcPath hash
886-
writeTQueue indexQueue $ \withHieDb -> do
886+
writeTaskQueue indexQueue $ \withHieDb -> do
887887
-- We are now in the worker thread
888888
-- Check if a newer index of this file has been scheduled, and if so skip this one
889889
newerScheduled <- atomically $ do

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module Development.IDE.Core.FileStore(
2525
) where
2626

2727
import Control.Concurrent.STM.Stats (STM, atomically)
28-
import Control.Concurrent.STM.TQueue (writeTQueue)
2928
import Control.Exception
3029
import Control.Lens ((^.))
3130
import Control.Monad.Extra
@@ -52,6 +51,7 @@ import Development.IDE.Types.Diagnostics
5251
import Development.IDE.Types.Location
5352
import Development.IDE.Types.Options
5453
import Development.IDE.Types.Shake (toKey)
54+
import Development.IDE.WorkerThread (writeTaskQueue)
5555
import HieDb.Create (deleteMissingRealFiles)
5656
import Ide.Logger (Pretty (pretty),
5757
Priority (Info),
@@ -82,7 +82,6 @@ data Log
8282
= LogCouldNotIdentifyReverseDeps !NormalizedFilePath
8383
| LogTypeCheckingReverseDeps !NormalizedFilePath !(Maybe [NormalizedFilePath])
8484
| LogShake Shake.Log
85-
| LogGetModificationTime !NormalizedFilePath
8685
deriving Show
8786

8887
instance Pretty Log where
@@ -95,8 +94,6 @@ instance Pretty Log where
9594
<> ":"
9695
<+> pretty (fmap (fmap show) reverseDepPaths)
9796
LogShake msg -> pretty msg
98-
LogGetModificationTime path ->
99-
"Getting modification time for" <+> viaShow path
10097

10198
addWatchedFileRule :: Recorder (WithPriority Log) -> (NormalizedFilePath -> Action Bool) -> Rules ()
10299
addWatchedFileRule recorder isWatched = defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \AddWatchedFile f -> do
@@ -113,7 +110,6 @@ addWatchedFileRule recorder isWatched = defineNoDiagnostics (cmapWithPrio LogSha
113110

114111
getModificationTimeRule :: Recorder (WithPriority Log) -> Rules ()
115112
getModificationTimeRule recorder = defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \(GetModificationTime_ missingFileDiags) file -> do
116-
logWith recorder Info $ LogGetModificationTime file
117113
getModificationTimeImpl missingFileDiags file
118114

119115
getModificationTimeImpl
@@ -306,7 +302,7 @@ typecheckParentsAction recorder nfp = do
306302
setSomethingModified :: VFSModified -> IdeState -> String -> IO [Key] -> IO ()
307303
setSomethingModified vfs state reason actionBetweenSession = do
308304
-- Update database to remove any files that might have been renamed/deleted
309-
atomically $ writeTQueue (indexQueue $ hiedbWriter $ shakeExtras state) (\withHieDb -> withHieDb deleteMissingRealFiles)
305+
atomically $ writeTaskQueue (indexQueue $ hiedbWriter $ shakeExtras state) (\withHieDb -> withHieDb deleteMissingRealFiles)
310306
void $ restartShakeSession (shakeExtras state) vfs reason [] actionBetweenSession
311307

312308
registerFileWatches :: [String] -> LSP.LspT Config IO Bool

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ instance Pretty Log where
5757
pretty = \case
5858
LogShake msg -> pretty msg
5959

60+
newtype OfInterestVar = OfInterestVar (Var (HashMap NormalizedFilePath FileOfInterestStatus))
61+
62+
instance IsIdeGlobal OfInterestVar
63+
6064
-- | The rule that initialises the files of interest state.
6165
ofInterestRules :: Recorder (WithPriority Log) -> Rules ()
6266
ofInterestRules recorder = do
@@ -75,6 +79,9 @@ ofInterestRules recorder = do
7579
summarize (IsFOI (Modified False)) = BS.singleton 2
7680
summarize (IsFOI (Modified True)) = BS.singleton 3
7781

82+
------------------------------------------------------------
83+
newtype GarbageCollectVar = GarbageCollectVar (Var Bool)
84+
instance IsIdeGlobal GarbageCollectVar
7885

7986
------------------------------------------------------------
8087
-- Exposed API
@@ -147,6 +154,10 @@ kick = do
147154

148155
liftIO $ progressUpdate progress ProgressCompleted
149156

157+
GarbageCollectVar var <- getIdeGlobalAction
158+
garbageCollectionScheduled <- liftIO $ readVar var
159+
when garbageCollectionScheduled $ do
160+
void garbageCollectDirtyKeys
161+
liftIO $ writeVar var False
150162

151163
signal (Proxy @"kick/done")
152-

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import Control.Lens ((^.))
2828
import Control.Monad
2929
import Data.Algorithm.Diff
3030
import Data.Bifunctor
31-
import Data.List
3231
import qualified Data.Text as T
3332
import qualified Data.Vector.Unboxed as V
3433
import qualified Language.LSP.Protocol.Lens as L

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ loadGhcSession recorder ghcSessionDepsConfig = do
722722
itExists <- getFileExists nfp
723723
when itExists $ void $ do
724724
use_ GetPhysicalModificationTime nfp
725-
logWith recorder Logger.Info $ LogDependencies file deps
725+
logWith recorder Logger.Debug $ LogDependencies file deps
726726
mapM_ addDependency deps
727727

728728
let cutoffHash = LBS.toStrict $ B.encode (hash (snd val))

0 commit comments

Comments
 (0)