@@ -49,6 +49,7 @@ module Development.Benchmark.Rules
4949 benchRules , MkBenchRules (.. ), BenchProject (.. ),
5050 csvRules ,
5151 svgRules ,
52+ eventlogRules ,
5253 allTargets ,
5354 GetExample (.. ), GetExamples (.. ),
5455 IsExample (.. ), RuleResultForExample ,
@@ -83,7 +84,7 @@ import GHC.Stack (HasCallStack)
8384import qualified Graphics.Rendering.Chart.Backend.Diagrams as E
8485import Graphics.Rendering.Chart.Easy ((.=) )
8586import qualified Graphics.Rendering.Chart.Easy as E
86- import System.Directory ( findExecutable , createDirectoryIfMissing )
87+ import System.Directory ( createDirectoryIfMissing , findExecutable , renameFile )
8788import System.FilePath
8889import qualified Text.ParserCombinators.ReadP as P
8990import Text.Read (Read (.. ), get ,
@@ -134,11 +135,11 @@ allTargets buildFolder = do
134135 ++ [ buildFolder </>
135136 getExampleName ex </>
136137 T. unpack (humanName ver) </>
137- escaped (escapeExperiment e) <.> mode <.> " svg "
138+ escaped (escapeExperiment e) <.> mode
138139 | e <- experiments,
139140 ex <- examples,
140141 ver <- versions,
141- mode <- [" " , " diff" ]
142+ mode <- [" svg " , " diff.svg " , " eventlog.html " ]
142143 ]
143144
144145--------------------------------------------------------------------------------
@@ -188,14 +189,14 @@ buildRules build MkBuildRules{..} = do
188189 [build -/- " binaries/*/" <> executableName
189190 ,build -/- " binaries/*/ghc.path"
190191 ] &%> \ [out, ghcPath] -> do
191- let [_, _binaries, _ver , _] = splitDirectories out
192+ let [_, _binaries, ver , _] = splitDirectories out
192193 liftIO $ createDirectoryIfMissing True $ dropFileName out
193194 commitid <- readFile' $ takeDirectory out </> " commitid"
194- cmd_ $ " git worktree add bench-temp " ++ commitid
195+ cmd_ $ " git worktree add bench-temp- " ++ ver ++ " " ++ commitid
195196 buildSystem <- askOracle $ GetBuildSystem ()
196- flip actionFinally (cmd_ (" git worktree remove bench-temp --force" :: String )) $ do
197- ghcLoc <- liftIO $ findGhc buildSystem " bench-temp "
198- buildProject buildSystem [Cwd " bench-temp" ] (" .." </> takeDirectory out)
197+ flip actionFinally (cmd_ (" git worktree remove bench-temp- " <> ver <> " --force" :: String )) $ do
198+ ghcLoc <- liftIO $ findGhc buildSystem ver
199+ buildProject buildSystem [Cwd $ " bench-temp- " <> ver ] (" .." </> takeDirectory out)
199200 writeFile' ghcPath ghcLoc
200201
201202--------------------------------------------------------------------------------
@@ -224,17 +225,19 @@ benchRules build benchResource MkBenchRules{..} = do
224225 priority 0 $
225226 [ build -/- " */*/*.csv" ,
226227 build -/- " */*/*.benchmark-gcStats" ,
228+ build -/- " */*/*.eventlog" ,
229+ build -/- " */*/*.hp" ,
227230 build -/- " */*/*.log"
228231 ]
229- &%> \ [outcsv, outGc, outLog] -> do
232+ &%> \ [outcsv, outGc, outEventLog, outHp, outLog] -> do
230233 let [_, exampleName, ver, exp ] = splitDirectories outcsv
231234 example <- fromMaybe (error $ " Unknown example " <> exampleName)
232235 <$> askOracle (GetExample exampleName)
233236 buildSystem <- askOracle $ GetBuildSystem ()
234237 setupRes <- setupProject
235238 liftIO $ createDirectoryIfMissing True $ dropFileName outcsv
236239 let exePath = build </> " binaries" </> ver </> executableName
237- exeExtraArgs = [" +RTS" , " -I0.5 " , " -S " <> takeFileName outGc, " -RTS" ]
240+ exeExtraArgs = [" +RTS" , " -l-a " , " -h " , " -ol " <> outEventLog, " -S " <> outGc, " -RTS" ]
238241 ghcPath = build </> " binaries" </> ver </> " ghc.path"
239242 experiment = Escaped $ dropExtension exp
240243 need [exePath, ghcPath]
@@ -247,8 +250,8 @@ benchRules build benchResource MkBenchRules{..} = do
247250 RemEnv " GHC_PACKAGE_PATH" ,
248251 AddPath [takeDirectory ghcPath, " ." ] []
249252 ]
250- BenchProject {.. }
251- cmd_ Shell $ " mv *.benchmark-gcStats " <> dropFileName outcsv
253+ BenchProject {.. }
254+ liftIO $ renameFile " ghcide.hp " $ dropFileName outcsv </> dropExtension exp <.> " hp "
252255
253256 -- extend csv output with allocation data
254257 csvContents <- liftIO $ lines <$> readFile outcsv
@@ -378,6 +381,11 @@ svgRules build = do
378381 title = show (unescapeExperiment exp ) <> " - live bytes over time"
379382 plotDiagram False diagram out
380383
384+ eventlogRules :: FilePattern -> Rules ()
385+ eventlogRules build = do
386+ build -/- " */*/*.eventlog.html" %> \ out -> do
387+ need [dropExtension out]
388+ cmd_ (" eventlog2html" :: String ) [dropExtension out]
381389
382390--------------------------------------------------------------------------------
383391--------------------------------------------------------------------------------
0 commit comments