@@ -14,10 +14,6 @@ module Development.IDE.Core.Rules(
14
14
IdeState , GetParsedModule (.. ), TransitiveDependencies (.. ),
15
15
Priority (.. ), GhcSessionIO (.. ), GetClientSettings (.. ),
16
16
-- * Functions
17
- --
18
- --
19
- --
20
- --
21
17
priorityTypeCheck ,
22
18
priorityGenerateCore ,
23
19
priorityFilesOfInterest ,
@@ -674,7 +670,11 @@ knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorde
674
670
getModuleGraphRule :: Recorder (WithPriority Log ) -> Rules ()
675
671
getModuleGraphRule recorder = defineNoFile (cmapWithPrio LogShake recorder) $ \ GetModuleGraph -> do
676
672
fs <- toKnownFiles <$> useNoFile_ GetKnownTargets
677
- (rawDepInfo, bm) <- rawDependencyInformation (HashSet. toList fs)
673
+ dependencyInfoForFiles (HashSet. toList fs)
674
+
675
+ dependencyInfoForFiles :: [NormalizedFilePath ] -> Action DependencyInformation
676
+ dependencyInfoForFiles fs = do
677
+ (rawDepInfo, bm) <- rawDependencyInformation fs
678
678
let (all_fs, _all_ids) = unzip $ HM. toList $ pathToIdMap $ rawPathIdMap rawDepInfo
679
679
mss <- map (fmap msrModSummary) <$> uses GetModSummaryWithoutTimestamps all_fs
680
680
#if MIN_VERSION_ghc(9,3,0)
@@ -767,11 +767,11 @@ loadGhcSession recorder ghcSessionDepsConfig = do
767
767
ghcSessionDepsDefinition fullModSummary ghcSessionDepsConfig env file
768
768
769
769
newtype GhcSessionDepsConfig = GhcSessionDepsConfig
770
- { checkForImportCycles :: Bool
770
+ { fullModuleGraph :: Bool
771
771
}
772
772
instance Default GhcSessionDepsConfig where
773
773
def = GhcSessionDepsConfig
774
- { checkForImportCycles = True
774
+ { fullModuleGraph = True
775
775
}
776
776
777
777
-- | Note [GhcSessionDeps]
@@ -790,15 +790,18 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
790
790
case mbdeps of
791
791
Nothing -> return Nothing
792
792
Just deps -> do
793
- when checkForImportCycles $ void $ uses_ ReportImportCycles deps
793
+ when fullModuleGraph $ void $ uses_ ReportImportCycles deps
794
794
ms <- msrModSummary <$> if fullModSummary
795
795
then use_ GetModSummary file
796
796
else use_ GetModSummaryWithoutTimestamps file
797
797
798
798
depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
799
799
ifaces <- uses_ GetModIface deps
800
800
let inLoadOrder = map (\ HiFileResult {.. } -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces
801
- mg <- depModuleGraph <$> useNoFile_ GetModuleGraph
801
+ mg <- depModuleGraph <$>
802
+ if fullModuleGraph
803
+ then useNoFile_ GetModuleGraph
804
+ else dependencyInfoForFiles [file]
802
805
session' <- liftIO $ mergeEnvs hsc mg ms inLoadOrder depSessions
803
806
804
807
-- Here we avoid a call to to `newHscEnvEqWithImportPaths`, which creates a new
@@ -1203,8 +1206,16 @@ newtype CompiledLinkables = CompiledLinkables { getCompiledLinkables :: Var (Mod
1203
1206
instance IsIdeGlobal CompiledLinkables
1204
1207
1205
1208
data RulesConfig = RulesConfig
1206
- { -- | Disable import cycle checking for improved performance in large codebases
1207
- checkForImportCycles :: Bool
1209
+ { -- | Share the computation for the entire module graph
1210
+ -- We usually compute the full module graph for the project
1211
+ -- and share it for all files.
1212
+ -- However, in large projects it might not be desirable to wait
1213
+ -- for computing the entire module graph before starting to
1214
+ -- typecheck a particular file.
1215
+ -- Disabling this drastically decreases sharing and is likely to
1216
+ -- increase memory usage if you have multiple files open
1217
+ -- Disabling this also disables checking for import cycles
1218
+ fullModuleGraph :: Bool
1208
1219
-- | Disable TH for improved performance in large codebases
1209
1220
, enableTemplateHaskell :: Bool
1210
1221
-- | Warning to show when TH is not supported by the current HLS binary
@@ -1241,7 +1252,7 @@ mainRule recorder RulesConfig{..} = do
1241
1252
reportImportCyclesRule recorder
1242
1253
typeCheckRule recorder
1243
1254
getDocMapRule recorder
1244
- loadGhcSession recorder def{checkForImportCycles }
1255
+ loadGhcSession recorder def{fullModuleGraph }
1245
1256
getModIfaceFromDiskRule recorder
1246
1257
getModIfaceFromDiskAndIndexRule recorder
1247
1258
getModIfaceRule recorder
0 commit comments