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