on master help sign in
Make --shake-profiling use the directory based profiling (#2378)

* Make --shake-profiling use the directory based profiling The single-file based profiling is rather useless in the IDE and I always found myself having to modify the source to set `profileDir` so this PR switches the CLI option to control that instead. * Add --shake-profiling to damlc ide

commit54fceeac4db3f6fa346a80fea89a02b87af2c3f2 authorMoritz Kiefer <moritz.kiefer@purelyfunctional.org> dateFri 2 Aug 2019, 15:21 (7 years ago) parent0601c59
2 files changed+9−14
src/Development/IDE/Core/Service.hs+2−6 src/Development/IDE/Core/Shake.hs+7−8
src/Development/IDE/Core/Service.hs+2−6
@@ -50,8 +50,8 @@ initialise mainRule toDiags logger options vfs =
5050 shakeOpen
5151 toDiags
5252 logger
53− (setProfiling options $
54− shakeOptions { shakeThreads = optThreads options
53+ (optShakeProfiling options)
54+ (shakeOptions { shakeThreads = optThreads options
5555 , shakeFiles = "/dev/null"
5656 }) $ do
5757 addIdeGlobal $ GlobalIdeOptions options
@@ -62,10 +62,6 @@ initialise mainRule toDiags logger options vfs =
6262writeProfile :: IdeState -> FilePath -> IO ()
6363writeProfile = shakeProfile
6464
65−setProfiling :: IdeOptions -> ShakeOptions -> ShakeOptions
66−setProfiling opts shakeOpts =
67− maybe shakeOpts (\p -> shakeOpts { shakeReport = [p], shakeTimings = True }) (optShakeProfiling opts)
68−
6965-- | Shutdown the Compiler Service.
7066shutdown :: IdeState -> IO ()
7167shutdown = shakeShut
src/Development/IDE/Core/Shake.hs+7−8
@@ -219,17 +219,15 @@ data IdeState = IdeState
219219 ,shakeAbort :: Var (IO ()) -- close whoever was running last
220220 ,shakeClose :: IO ()
221221 ,shakeExtras :: ShakeExtras
222+ ,shakeProfileDir :: Maybe FilePath
222223 }
223224
224−profileDir :: Maybe FilePath
225−profileDir = Nothing -- set to Just the directory you want profile reports to appear in
226−
227225
228226-- This is debugging code that generates a series of profiles, if the Boolean is true
229−shakeRunDatabaseProfile :: ShakeDatabase -> [Action a] -> IO [a]
230−shakeRunDatabaseProfile shakeDb acts = do
227+shakeRunDatabaseProfile :: Maybe FilePath -> ShakeDatabase -> [Action a] -> IO [a]
228+shakeRunDatabaseProfile mbProfileDir shakeDb acts = do
231229 (time, (res,_)) <- duration $ shakeRunDatabase shakeDb acts
232− whenJust profileDir $ \dir -> do
230+ whenJust mbProfileDir $ \dir -> do
233231 count <- modifyVar profileCounter $ \x -> let y = x+1 in return (y,y)
234232 let file = "ide-" ++ profileStartTime ++ "-" ++ takeEnd 5 ("0000" ++ show count) ++ "-" ++ showDP 2 time <.> "html"
235233 shakeProfileDatabase shakeDb $ dir </> file
@@ -264,10 +262,11 @@ getValues state key file = do
264262-- | Open a 'IdeState', should be shut using 'shakeShut'.
265263shakeOpen :: (LSP.FromServerMessage -> IO ()) -- ^ diagnostic handler
266264 -> Logger
265+ -> Maybe FilePath
267266 -> ShakeOptions
268267 -> Rules ()
269268 -> IO IdeState
270−shakeOpen eventer logger opts rules = do
269+shakeOpen eventer logger shakeProfileDir opts rules = do
271270 shakeExtras <- do
272271 globals <- newVar HMap.empty
273272 state <- newVar HMap.empty
@@ -336,7 +335,7 @@ shakeRun IdeState{shakeExtras=ShakeExtras{..}, ..} acts = modifyVar shakeAbort $
336335 logDebug logger $ T.pack $ "Starting shakeRun (aborting the previous one took " ++ showDuration stopTime ++ ")"
337336 bar <- newBarrier
338337 start <- offsetTime
339− thread <- forkFinally (shakeRunDatabaseProfile shakeDb acts) $ \res -> do
338+ thread <- forkFinally (shakeRunDatabaseProfile shakeProfileDir shakeDb acts) $ \res -> do
340339 signalBarrier bar res
341340 runTime <- start
342341 let res' = case res of