@@ -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 ,
@@ -665,7 +661,11 @@ knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorde
665
661
getModuleGraphRule :: Recorder (WithPriority Log ) -> Rules ()
666
662
getModuleGraphRule recorder = defineNoFile (cmapWithPrio LogShake recorder) $ \ GetModuleGraph -> do
667
663
fs <- toKnownFiles <$> useNoFile_ GetKnownTargets
668
- (rawDepInfo, bm) <- rawDependencyInformation (HashSet. toList fs)
664
+ dependencyInfoForFiles (HashSet. toList fs)
665
+
666
+ dependencyInfoForFiles :: [NormalizedFilePath ] -> Action DependencyInformation
667
+ dependencyInfoForFiles fs = do
668
+ (rawDepInfo, bm) <- rawDependencyInformation fs
669
669
let (all_fs, _all_ids) = unzip $ HM. toList $ pathToIdMap $ rawPathIdMap rawDepInfo
670
670
mss <- map (fmap msrModSummary) <$> uses GetModSummaryWithoutTimestamps all_fs
671
671
#if MIN_VERSION_ghc(9,3,0)
@@ -758,11 +758,11 @@ loadGhcSession recorder ghcSessionDepsConfig = do
758
758
ghcSessionDepsDefinition fullModSummary ghcSessionDepsConfig env file
759
759
760
760
newtype GhcSessionDepsConfig = GhcSessionDepsConfig
761
- { checkForImportCycles :: Bool
761
+ { fullModuleGraph :: Bool
762
762
}
763
763
instance Default GhcSessionDepsConfig where
764
764
def = GhcSessionDepsConfig
765
- { checkForImportCycles = True
765
+ { fullModuleGraph = True
766
766
}
767
767
768
768
-- | Note [GhcSessionDeps]
@@ -781,15 +781,18 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
781
781
case mbdeps of
782
782
Nothing -> return Nothing
783
783
Just deps -> do
784
- when checkForImportCycles $ void $ uses_ ReportImportCycles deps
784
+ when fullModuleGraph $ void $ uses_ ReportImportCycles deps
785
785
ms <- msrModSummary <$> if fullModSummary
786
786
then use_ GetModSummary file
787
787
else use_ GetModSummaryWithoutTimestamps file
788
788
789
789
depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
790
790
ifaces <- uses_ GetModIface deps
791
791
let inLoadOrder = map (\ HiFileResult {.. } -> HomeModInfo hirModIface hirModDetails Nothing ) ifaces
792
- mg <- depModuleGraph <$> useNoFile_ GetModuleGraph
792
+ mg <- depModuleGraph <$>
793
+ if fullModuleGraph
794
+ then useNoFile_ GetModuleGraph
795
+ else dependencyInfoForFiles [file]
793
796
session' <- liftIO $ mergeEnvs hsc mg ms inLoadOrder depSessions
794
797
795
798
Just <$> liftIO (newHscEnvEqWithImportPaths (envImportPaths env) session' [] )
@@ -1189,8 +1192,16 @@ newtype CompiledLinkables = CompiledLinkables { getCompiledLinkables :: Var (Mod
1189
1192
instance IsIdeGlobal CompiledLinkables
1190
1193
1191
1194
data RulesConfig = RulesConfig
1192
- { -- | Disable import cycle checking for improved performance in large codebases
1193
- checkForImportCycles :: Bool
1195
+ { -- | Share the computation for the entire module graph
1196
+ -- We usually compute the full module graph for the project
1197
+ -- and share it for all files.
1198
+ -- However, in large projects it might not be desirable to wait
1199
+ -- for computing the entire module graph before starting to
1200
+ -- typecheck a particular file.
1201
+ -- Disabling this drastically decreases sharing and is likely to
1202
+ -- increase memory usage if you have multiple files open
1203
+ -- Disabling this also disables checking for import cycles
1204
+ fullModuleGraph :: Bool
1194
1205
-- | Disable TH for improved performance in large codebases
1195
1206
, enableTemplateHaskell :: Bool
1196
1207
-- | Warning to show when TH is not supported by the current HLS binary
@@ -1227,7 +1238,7 @@ mainRule recorder RulesConfig{..} = do
1227
1238
reportImportCyclesRule recorder
1228
1239
typeCheckRule recorder
1229
1240
getDocMapRule recorder
1230
- loadGhcSession recorder def{checkForImportCycles }
1241
+ loadGhcSession recorder def{fullModuleGraph }
1231
1242
getModIfaceFromDiskRule recorder
1232
1243
getModIfaceFromDiskAndIndexRule recorder
1233
1244
getModIfaceRule recorder
0 commit comments