Skip to content

Commit 2bb631c

Browse files
committed
[benchmarks] Collect heap profiles
1 parent 5002b36 commit 2bb631c

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

ghcide/bench/hist/Main.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ main = shakeArgs shakeOptions {shakeChange = ChangeModtimeAndDigest, shakeThread
7474
benchRules build resource (MkBenchRules (askOracle $ GetSamples ()) benchGhcide "ghcide")
7575
csvRules build
7676
svgRules build
77+
eventlogRules build
7778
action $ allTargets build
7879

7980
ghcideBuildRules :: MkBuildRules BuildSystem
@@ -122,6 +123,7 @@ buildGhcide Cabal args out = do
122123
,"--install-method=copy"
123124
,"--overwrite-policy=always"
124125
,"--ghc-options=-rtsopts"
126+
,"--ghc-options=-eventlog"
125127
]
126128

127129
buildGhcide Stack args out =
@@ -131,6 +133,7 @@ buildGhcide Stack args out =
131133
,"ghcide:ghcide"
132134
,"--copy-bins"
133135
,"--ghc-options=-rtsopts"
136+
,"--ghc-options=-eventlog"
134137
]
135138

136139
benchGhcide

ghcide/ghcide.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ benchmark benchHist
219219
hs-source-dirs: bench/hist bench/lib
220220
other-modules: Experiments.Types
221221
build-tool-depends:
222-
ghcide:ghcide-bench
222+
ghcide:ghcide-bench,
223+
eventlog2html:eventlog2html
223224
default-extensions:
224225
BangPatterns
225226
DeriveFunctor

shake-bench/src/Development/Benchmark/Rules.hs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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,
@@ -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
--------------------------------------------------------------------------------
@@ -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+
cmd_ Shell $ "mv 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 " <> dropExtension out
381389

382390
--------------------------------------------------------------------------------
383391
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)