Skip to content

Produce heap profiles the old fashioned way, from .hp files #1261

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 1 commit into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions ghcide/bench/hist/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ main = shakeArgs shakeOptions {shakeChange = ChangeModtimeAndDigest, shakeThread
benchRules build resource (MkBenchRules (askOracle $ GetSamples ()) benchGhcide "ghcide")
csvRules build
svgRules build
eventlogRules build
heapProfileRules build
action $ allTargets build

ghcideBuildRules :: MkBuildRules BuildSystem
Expand Down Expand Up @@ -123,7 +123,6 @@ buildGhcide Cabal args out = do
,"--install-method=copy"
,"--overwrite-policy=always"
,"--ghc-options=-rtsopts"
,"--ghc-options=-eventlog"
]

buildGhcide Stack args out =
Expand All @@ -133,7 +132,6 @@ buildGhcide Stack args out =
,"ghcide:ghcide"
,"--copy-bins"
,"--ghc-options=-rtsopts"
,"--ghc-options=-eventlog"
]

benchGhcide
Expand Down
2 changes: 1 addition & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ benchmark benchHist
other-modules: Experiments.Types
build-tool-depends:
ghcide:ghcide-bench,
eventlog2html:eventlog2html
hp2pretty:hp2pretty
default-extensions:
BangPatterns
DeriveFunctor
Expand Down
22 changes: 12 additions & 10 deletions shake-bench/src/Development/Benchmark/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Development.Benchmark.Rules
benchRules, MkBenchRules(..), BenchProject(..),
csvRules,
svgRules,
eventlogRules,
heapProfileRules,
allTargets,
GetExample(..), GetExamples(..),
IsExample(..), RuleResultForExample,
Expand Down Expand Up @@ -139,7 +139,7 @@ allTargets buildFolder = do
| e <- experiments,
ex <- examples,
ver <- versions,
mode <- ["svg", "diff.svg","eventlog.html"]
mode <- ["svg", "diff.svg","heap.svg"]
]

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -225,19 +225,18 @@ benchRules build benchResource MkBenchRules{..} = do
priority 0 $
[ build -/- "*/*/*.csv",
build -/- "*/*/*.benchmark-gcStats",
build -/- "*/*/*.eventlog",
build -/- "*/*/*.hp",
build -/- "*/*/*.log"
]
&%> \[outcsv, outGc, outEventLog, outHp, outLog] -> do
&%> \[outcsv, outGc, outHp, outLog] -> do
let [_, exampleName, ver, exp] = splitDirectories outcsv
example <- fromMaybe (error $ "Unknown example " <> exampleName)
<$> askOracle (GetExample exampleName)
buildSystem <- askOracle $ GetBuildSystem ()
setupRes <- setupProject
liftIO $ createDirectoryIfMissing True $ dropFileName outcsv
let exePath = build </> "binaries" </> ver </> executableName
exeExtraArgs = ["+RTS", "-l-a", "-h", "-ol" <> outEventLog, "-S" <> outGc, "-RTS"]
exeExtraArgs = ["+RTS", "-h", "-S" <> outGc, "-RTS"]
ghcPath = build </> "binaries" </> ver </> "ghc.path"
experiment = Escaped $ dropExtension exp
need [exePath, ghcPath]
Expand Down Expand Up @@ -381,11 +380,14 @@ svgRules build = do
title = show (unescapeExperiment exp) <> " - live bytes over time"
plotDiagram False diagram out

eventlogRules :: FilePattern -> Rules ()
eventlogRules build = do
build -/- "*/*/*.eventlog.html" %> \out -> do
need [dropExtension out]
cmd_ ("eventlog2html" :: String) [dropExtension out]
heapProfileRules :: FilePattern -> Rules ()
heapProfileRules build = do
priority 3 $
build -/- "*/*/*.heap.svg" %> \out -> do
let hpFile = dropExtension (dropExtension out) <.> "hp"
need [hpFile]
cmd_ ("hp2pretty" :: String) [hpFile]
liftIO $ renameFile (dropExtension hpFile <.> "svg") out

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Expand Down