From aecb10024b6a9159ffcbf30b2faefc950b16deb0 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Wed, 8 Dec 2021 08:57:44 +0000 Subject: Use file hash cache when hashing object file dependencies This fixes the immediate problem that we hash the same file multiple different times which causes quite a noticeably performance regression. In the future we can probably do better than this by storing the implementation hash in the interface file rather than dependending on hashing the object file. Related to #20604 which notes some inefficiencies with the current recompilation logic. Closes #20790 ------------------------- Metric Decrease: T14052Type ------------------------- --- compiler/GHC/HsToCore/Usage.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/GHC/HsToCore/Usage.hs b/compiler/GHC/HsToCore/Usage.hs index 21bbc6eec1..fa4f08c2ef 100644 --- a/compiler/GHC/HsToCore/Usage.hs +++ b/compiler/GHC/HsToCore/Usage.hs @@ -39,6 +39,7 @@ import qualified Data.Map as Map import GHC.Linker.Types import GHC.Linker.Loader ( getLoaderState ) import GHC.Types.SourceFile +import GHC.Unit.Finder {- Note [Module self-dependency] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -146,7 +147,7 @@ mkObjectUsage pit hsc_env mnwib = do msg m = moduleNameString (moduleName m) ++ "[TH] changed" - fing mmsg fn = UsageFile fn <$> getFileHash fn <*> pure mmsg + fing mmsg fn = UsageFile fn <$> lookupFileCache (hsc_FC hsc_env) fn <*> pure mmsg unlinkedToUsage m ul = case nameOfObject_maybe ul of -- cgit v1.2.1