-
-
Notifications
You must be signed in to change notification settings - Fork 398
Compute Partial module graph fingerprints #4594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
824c508
4cc1c37
fd903c4
8afa778
bebead5
4ec8a6f
e87f1d1
5f58042
be60d4d
a1fc61c
2a63484
faf57ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,7 +472,7 @@ | |
reportImportCyclesRule :: Recorder (WithPriority Log) -> Rules () | ||
reportImportCyclesRule recorder = | ||
defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ReportImportCycles file -> fmap (\errs -> if null errs then (Just "1",([], Just ())) else (Nothing, (errs, Nothing))) $ do | ||
DependencyInformation{..} <- useNoFile_ GetModuleGraph | ||
DependencyInformation{..} <- use_ GetFileModuleGraph file | ||
case pathToId depPathIdMap file of | ||
-- The header of the file does not parse, so it can't be part of any import cycles. | ||
Nothing -> pure [] | ||
|
@@ -608,7 +608,7 @@ | |
-- very expensive. | ||
when (foi == NotFOI) $ | ||
logWith recorder Logger.Warning $ LogTypecheckedFOI file | ||
typeCheckRuleDefinition hsc pm | ||
typeCheckRuleDefinition hsc pm file | ||
|
||
knownFilesRule :: Recorder (WithPriority Log) -> Rules () | ||
knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorder) $ \GetKnownTargets -> do | ||
|
@@ -628,6 +628,12 @@ | |
fs <- toKnownFiles <$> useNoFile_ GetKnownTargets | ||
dependencyInfoForFiles (HashSet.toList fs) | ||
|
||
getModuleGraphSingleFileRule :: Recorder (WithPriority Log) -> Rules () | ||
getModuleGraphSingleFileRule recorder = | ||
defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \GetFileModuleGraph file -> do | ||
di <- useNoFile_ GetModuleGraph | ||
return (fingerprintToBS <$> lookupFingerprint file di, ([], Just di)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for correctness reasons we might need to restrict |
||
|
||
dependencyInfoForFiles :: [NormalizedFilePath] -> Action (BS.ByteString, DependencyInformation) | ||
dependencyInfoForFiles fs = do | ||
(rawDepInfo, bm) <- rawDependencyInformation fs | ||
|
@@ -643,7 +649,10 @@ | |
go (Just ms) _ = Just $ ModuleNode [] ms | ||
go _ _ = Nothing | ||
mg = mkModuleGraph mns | ||
pure (fingerprintToBS $ Util.fingerprintFingerprints $ map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg) | ||
let shallowFingers = IntMap.fromList $ foldr' (\(i, m) acc -> case m of | ||
Just x -> (getFilePathId i,msrFingerprint x):acc | ||
Nothing -> acc) [] $ zip _all_ids msrs | ||
pure (fingerprintToBS $ Util.fingerprintFingerprints $ map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg shallowFingers) | ||
|
||
-- This is factored out so it can be directly called from the GetModIface | ||
-- rule. Directly calling this rule means that on the initial load we can | ||
|
@@ -652,14 +661,15 @@ | |
typeCheckRuleDefinition | ||
:: HscEnv | ||
-> ParsedModule | ||
-> NormalizedFilePath | ||
-> Action (IdeResult TcModuleResult) | ||
typeCheckRuleDefinition hsc pm = do | ||
typeCheckRuleDefinition hsc pm fp = do | ||
IdeOptions { optDefer = defer } <- getIdeOptions | ||
|
||
unlift <- askUnliftIO | ||
let dets = TypecheckHelpers | ||
{ getLinkables = unliftIO unlift . uses_ GetLinkable | ||
, getModuleGraph = unliftIO unlift $ useNoFile_ GetModuleGraph | ||
, getModuleGraph = unliftIO unlift $ use_ GetFileModuleGraph fp | ||
} | ||
addUsageDependencies $ liftIO $ | ||
typecheckModule defer hsc dets pm | ||
|
@@ -758,7 +768,7 @@ | |
let inLoadOrder = map (\HiFileResult{..} -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces | ||
mg <- do | ||
if fullModuleGraph | ||
then depModuleGraph <$> useNoFile_ GetModuleGraph | ||
then depModuleGraph <$> use_ GetFileModuleGraph file | ||
else do | ||
let mgs = map hsc_mod_graph depSessions | ||
-- On GHC 9.4+, the module graph contains not only ModSummary's but each `ModuleNode` in the graph | ||
|
@@ -771,7 +781,7 @@ | |
nubOrdOn mkNodeKey (ModuleNode final_deps ms : concatMap mgModSummaries' mgs) | ||
liftIO $ evaluate $ liftRnf rwhnf module_graph_nodes | ||
return $ mkModuleGraph module_graph_nodes | ||
de <- useNoFile_ GetModuleGraph | ||
de <- use_ GetFileModuleGraph file | ||
session' <- liftIO $ mergeEnvs hsc mg de ms inLoadOrder depSessions | ||
|
||
-- Here we avoid a call to to `newHscEnvEqWithImportPaths`, which creates a new | ||
|
@@ -800,8 +810,8 @@ | |
{ source_version = ver | ||
, old_value = m_old | ||
, get_file_version = use GetModificationTime_{missingFileDiagnostics = False} | ||
, get_linkable_hashes = \fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs | ||
Check warning on line 813 in ghcide/src/Development/IDE/Core/Rules.hs
|
||
, get_module_graph = useNoFile_ GetModuleGraph | ||
, get_module_graph = use_ GetFileModuleGraph f | ||
, regenerate = regenerateHiFile session f ms | ||
} | ||
hsc_env' <- setFileCacheHook (hscEnv session) | ||
|
@@ -977,7 +987,7 @@ | |
Just pm -> do | ||
-- Invoke typechecking directly to update it without incurring a dependency | ||
-- on the parsed module and the typecheck rules | ||
(diags', mtmr) <- typeCheckRuleDefinition hsc pm | ||
(diags', mtmr) <- typeCheckRuleDefinition hsc pm f | ||
case mtmr of | ||
Nothing -> pure (diags', Nothing) | ||
Just tmr -> do | ||
|
@@ -1093,7 +1103,7 @@ | |
-- thus bump its modification time, forcing this rule to be rerun every time. | ||
exists <- liftIO $ doesFileExist obj_file | ||
mobj_time <- liftIO $ | ||
if exists | ||
Check warning on line 1106 in ghcide/src/Development/IDE/Core/Rules.hs
|
||
then Just <$> getModTime obj_file | ||
else pure Nothing | ||
case mobj_time of | ||
|
@@ -1135,7 +1145,7 @@ | |
| "boot" `isSuffixOf` fromNormalizedFilePath file = | ||
pure (Just $ encodeLinkableType Nothing, Just Nothing) | ||
needsCompilationRule file = do | ||
graph <- useNoFile GetModuleGraph | ||
graph <- use GetFileModuleGraph file | ||
soulomoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res <- case graph of | ||
-- Treat as False if some reverse dependency header fails to parse | ||
Nothing -> pure Nothing | ||
|
@@ -1226,6 +1236,7 @@ | |
getModIfaceRule recorder | ||
getModSummaryRule templateHaskellWarning recorder | ||
getModuleGraphRule recorder | ||
getModuleGraphSingleFileRule recorder | ||
getFileHashRule recorder | ||
knownFilesRule recorder | ||
getClientSettingsRule recorder | ||
|
Uh oh!
There was an error while loading. Please reload this page.