From 08d6aaa0d39df8ed8191604c5b0b35ed66c481dc Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Tue, 23 Nov 2021 14:06:49 +0000 Subject: [PATCH] Add extra logging for GC (#2388) --- ghcide/src/Development/IDE/Core/Shake.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index 692bee21bb..f2bb83a92b 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -618,11 +618,13 @@ shakeRestart IdeState{..} reason acts = (stopTime,()) <- duration (cancelShakeSession runner) res <- shakeDatabaseProfile shakeDb backlog <- readIORef $ dirtyKeys shakeExtras + queue <- atomically $ peekInProgress $ actionQueue shakeExtras let profile = case res of Just fp -> ", profile saved at " <> fp _ -> "" - let msg = T.pack $ "Restarting build session " ++ reason' ++ keysMsg ++ abortMsg + let msg = T.pack $ "Restarting build session " ++ reason' ++ queueMsg ++ keysMsg ++ abortMsg reason' = "due to " ++ reason + queueMsg = " with queue " ++ show (map actionName queue) keysMsg = " for keys " ++ show (HSet.toList backlog) ++ " " abortMsg = "(aborting the previous one took " ++ showDuration stopTime ++ profile ++ ")" logDebug (logger shakeExtras) msg @@ -700,7 +702,8 @@ newSession extras@ShakeExtras{..} shakeDb acts reason = do -- The inferred type signature doesn't work in ghc >= 9.0.1 workRun :: (forall b. IO b -> IO b) -> IO (IO ()) workRun restore = withSpan "Shake session" $ \otSpan -> do - setTag otSpan "_reason" (fromString reason) + setTag otSpan "reason" (fromString reason) + setTag otSpan "queue" (fromString $ unlines $ map actionName reenqueued) whenJust allPendingKeys $ \kk -> setTag otSpan "keys" (BS8.pack $ unlines $ map show $ toList kk) let keysActs = pumpActionThread otSpan : map (run otSpan) (reenqueued ++ acts) res <- try @SomeException $ @@ -893,7 +896,7 @@ useWithStaleFast' key file = do -- Async trigger the key to be built anyway because we want to -- keep updating the value in the key. - wait <- delayedAction $ mkDelayedAction ("C:" ++ show key) Debug $ use key file + wait <- delayedAction $ mkDelayedAction ("C:" ++ show key ++ ":" ++ fromNormalizedFilePath file) Debug $ use key file s@ShakeExtras{state} <- askShake r <- liftIO $ getValues state key file