diff --git a/ghcide/exe/Arguments.hs b/ghcide/exe/Arguments.hs index b1e1d218ea..508bdaade1 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") diff --git a/ghcide/src/Development/IDE/Core/Service.hs b/ghcide/src/Development/IDE/Core/Service.hs index 542f06d079..59f20deed1 100644 --- a/ghcide/src/Development/IDE/Core/Service.hs +++ b/ghcide/src/Development/IDE/Core/Service.hs @@ -12,12 +12,12 @@ module Development.IDE.Core.Service( getIdeOptions, getIdeOptionsIO, IdeState, initialise, shutdown, runAction, - writeProfile, getDiagnostics, ideLogger, updatePositionMapping, ) where +import Control.Applicative ((<|>)) import Development.IDE.Core.Debouncer import Development.IDE.Core.FileExists (fileExistsRules) import Development.IDE.Core.OfInterest @@ -30,6 +30,7 @@ import qualified Language.LSP.Types as LSP import Control.Monad import Development.IDE.Core.Shake +import System.Environment (lookupEnv) ------------------------------------------------------------ @@ -46,13 +47,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 @@ -65,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