Skip to content

GHCIDE_BUILD_PROFILING env var #2125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ghcide/exe/Arguments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 8 additions & 6 deletions ghcide/src/Development/IDE/Core/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +30,7 @@ import qualified Language.LSP.Types as LSP

import Control.Monad
import Development.IDE.Core.Shake
import System.Environment (lookupEnv)


------------------------------------------------------------
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..),
Expand Down Expand Up @@ -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

Expand Down