From 38f7c46161885a4fa1d4e7426bbe6fbbe05382a0 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 16 May 2021 09:30:52 +0100 Subject: [PATCH 1/2] Trace more Shake evaluation details --- ghcide/src/Development/IDE/Core/Shake.hs | 10 +++++----- ghcide/src/Development/IDE/Core/Tracing.hs | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index f4b702b794..499d8b043c 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -829,9 +829,9 @@ defineEarlyCutoff :: IdeRule k v => RuleBody k v -> Rules () -defineEarlyCutoff (Rule op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file isSuccess $ do +defineEarlyCutoff (Rule op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file mode isSuccess $ do defineEarlyCutoff' True key file old mode $ op key file -defineEarlyCutoff (RuleNoDiagnostics op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file isSuccess $ do +defineEarlyCutoff (RuleNoDiagnostics op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file mode isSuccess $ do defineEarlyCutoff' False key file old mode $ second (mempty,) <$> op key file defineNoFile :: IdeRule k v => (k -> Action v) -> Rules () @@ -904,9 +904,9 @@ defineEarlyCutoff' doDiagnostics key file old mode action = do (encodeShakeValue bs) $ A res -isSuccess :: RunResult (A v) -> Bool -isSuccess (RunResult _ _ (A Failed{})) = False -isSuccess _ = True +isSuccess :: A v -> Bool +isSuccess (A Failed{}) = False +isSuccess _ = True -- | Rule type, input file data QDisk k = QDisk k NormalizedFilePath diff --git a/ghcide/src/Development/IDE/Core/Tracing.hs b/ghcide/src/Development/IDE/Core/Tracing.hs index db0acc27b5..6f4f3e830a 100644 --- a/ghcide/src/Development/IDE/Core/Tracing.hs +++ b/ghcide/src/Development/IDE/Core/Tracing.hs @@ -33,6 +33,7 @@ import Development.IDE.Core.RuleTypes (GhcSession (GhcSession), GhcSessionDeps (GhcSessionDeps), GhcSessionIO (GhcSessionIO)) import Development.IDE.Graph (Action, actionBracket) +import Development.IDE.Graph.Rule import Development.IDE.Types.Location (Uri (..)) import Development.IDE.Types.Logger (Logger, logDebug, logInfo) import Development.IDE.Types.Shake (Key (..), Value, @@ -77,21 +78,27 @@ otTracedAction :: Show k => k -- ^ The Action's Key -> NormalizedFilePath -- ^ Path to the file the action was run for - -> (a -> Bool) -- ^ Did this action succeed? - -> Action a -- ^ The action - -> Action a -otTracedAction key file success act + -> RunMode + -> (a -> Bool) + -> Action (RunResult a) -- ^ The action + -> Action (RunResult a) +otTracedAction key file mode success act | userTracingEnabled = actionBracket (do sp <- beginSpan (fromString (show key)) setTag sp "File" (fromString $ fromNormalizedFilePath file) + setTag sp "Mode" (fromString $ show mode) return sp ) endSpan (\sp -> do res <- act - unless (success res) $ setTag sp "error" "1" + unless (success $ runValue res) $ setTag sp "error" "1" + setTag sp "changed" $ case res of + RunResult ChangedRecomputeSame _ _ -> "0" + RunResult ChangedNothing _ _ -> "0" + RunResult ChangedRecomputeDiff _ _ -> "0" return res) | otherwise = act From 9ac39e812d796323aca3c7b057dc0f4a30ef7878 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Mon, 24 May 2021 07:43:10 +0100 Subject: [PATCH 2/2] Fix changed --- ghcide/src/Development/IDE/Core/Tracing.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Tracing.hs b/ghcide/src/Development/IDE/Core/Tracing.hs index 6f4f3e830a..1c773587bc 100644 --- a/ghcide/src/Development/IDE/Core/Tracing.hs +++ b/ghcide/src/Development/IDE/Core/Tracing.hs @@ -96,9 +96,7 @@ otTracedAction key file mode success act res <- act unless (success $ runValue res) $ setTag sp "error" "1" setTag sp "changed" $ case res of - RunResult ChangedRecomputeSame _ _ -> "0" - RunResult ChangedNothing _ _ -> "0" - RunResult ChangedRecomputeDiff _ _ -> "0" + RunResult x _ _ -> fromString $ show x return res) | otherwise = act