From c09c6152056c3f20dba746735258252c4d4e4ca8 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 22 Aug 2021 17:23:41 +0200 Subject: [PATCH 1/3] GHCIDE_BUILD_PROFILING --- ghcide/src/Development/IDE/Core/Service.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Service.hs b/ghcide/src/Development/IDE/Core/Service.hs index 542f06d079..2c88f7654f 100644 --- a/ghcide/src/Development/IDE/Core/Service.hs +++ b/ghcide/src/Development/IDE/Core/Service.hs @@ -18,6 +18,7 @@ module Development.IDE.Core.Service( updatePositionMapping, ) where +import Control.Applicative ((<|>)) import Development.IDE.Core.Debouncer import Development.IDE.Core.FileExists (fileExistsRules) import Development.IDE.Core.OfInterest @@ -30,6 +31,7 @@ import qualified Language.LSP.Types as LSP import Control.Monad import Development.IDE.Core.Shake +import System.Environment (lookupEnv) ------------------------------------------------------------ @@ -46,13 +48,17 @@ initialise :: Config -> HieDb -> IndexQueue -> IO IdeState -initialise defaultConfig mainRule lspEnv logger debouncer options vfs hiedb hiedbChan = +initialise defaultConfig mainRule lspEnv logger debouncer options vfs hiedb hiedbChan = do + shakeProfiling <- do + let fromConf = optShakeProfiling options + fromEnv <- lookupEnv "GHCIDE_BUILD_PROFILING" + return $ fromConf <|> fromEnv shakeOpen lspEnv defaultConfig logger debouncer - (optShakeProfiling options) + shakeProfiling (optReportProgress options) (optTesting options) hiedb From cda26cda72b1a35e52cea9d8b2639034e2937252 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 22 Aug 2021 19:27:43 +0200 Subject: [PATCH 2/3] profile before shutdown --- ghcide/src/Development/IDE/Core/Service.hs | 4 ---- ghcide/src/Development/IDE/Core/Shake.hs | 5 +---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Service.hs b/ghcide/src/Development/IDE/Core/Service.hs index 2c88f7654f..59f20deed1 100644 --- a/ghcide/src/Development/IDE/Core/Service.hs +++ b/ghcide/src/Development/IDE/Core/Service.hs @@ -12,7 +12,6 @@ module Development.IDE.Core.Service( getIdeOptions, getIdeOptionsIO, IdeState, initialise, shutdown, runAction, - writeProfile, getDiagnostics, ideLogger, updatePositionMapping, @@ -71,9 +70,6 @@ initialise defaultConfig mainRule lspEnv logger debouncer options vfs hiedb hied fileExistsRules lspEnv vfs mainRule -writeProfile :: IdeState -> FilePath -> IO () -writeProfile = shakeProfile - -- | Shutdown the Compiler Service. shutdown :: IdeState -> IO () shutdown = shakeShut diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index be4527bf58..5d6607a5da 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -31,7 +31,6 @@ module Development.IDE.Core.Shake( GetModificationTime(GetModificationTime, GetModificationTime_, missingFileDiagnostics), shakeOpen, shakeShut, shakeEnqueue, - shakeProfile, newSession, use, useNoFile, uses, useWithStaleFast, useWithStaleFast', delayedAction, FastResult(..), @@ -550,14 +549,12 @@ shakeSessionInit IdeState{..} = do initSession <- newSession shakeExtras shakeDb [] putMVar shakeSession initSession -shakeProfile :: IdeState -> FilePath -> IO () -shakeProfile IdeState{..} = shakeProfileDatabase shakeDb - shakeShut :: IdeState -> IO () shakeShut IdeState{..} = withMVar shakeSession $ \runner -> do -- Shake gets unhappy if you try to close when there is a running -- request so we first abort that. void $ cancelShakeSession runner + void $ shakeDatabaseProfile shakeDb shakeClose progressStop $ progress shakeExtras From 4150ea4ad4feda408ff33b98a7c38a8cd0578629 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 22 Aug 2021 21:24:07 +0200 Subject: [PATCH 3/3] mention env var in --help --- ghcide/exe/Arguments.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/exe/Arguments.hs b/ghcide/exe/Arguments.hs index 9f27265dc2..245b54e728 100644 --- a/ghcide/exe/Arguments.hs +++ b/ghcide/exe/Arguments.hs @@ -31,7 +31,7 @@ arguments :: IdePlugins IdeState -> Parser Arguments arguments plugins = Arguments <$> optional (strOption $ long "cwd" <> metavar "DIR" <> help "Change to this directory") <*> switch (long "version" <> help "Show ghcide and GHC versions") - <*> optional (strOption $ long "shake-profiling" <> metavar "DIR" <> help "Dump profiling reports to this directory") + <*> optional (strOption $ long "shake-profiling" <> metavar "DIR" <> help "Dump profiling reports to this directory (env var: GHCIDE_BUILD_PROFILING)") <*> switch (long "ot-memory-profiling" <> help "Record OpenTelemetry info to the eventlog. Needs the -l RTS flag to have an effect") <*> switch (long "test" <> help "Enable additional lsp messages used by the testsuite") <*> switch (long "test-no-kick" <> help "Disable kick. Useful for testing cancellation")