<html><head></head><body>There is the "useful tools" page [1] which has mentioned the ghc-utils repository where the aforementioned script lives for a few years now. That being said, I get the impression that not many people have found it via this page. Everyone who I know of who has used anything in ghc-utils has discovered it via word of mouth.<br><br>I'm not sure what to do about this. The page isn't *that* buried: from the wiki home page one arrives at it via the link path Working Conventions/Various tools.<br><br>Cheers,<br><br>- Ben <br><br><div class="gmail_quote">On January 4, 2020 8:51:07 PM EST, Richard Eisenberg <rae@richarde.dev> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Hi Ben,<br><br>This sounds great. Is there a place on the wiki to catalog tools like this?<br><br>Thanks for telling us about it!<br>Richard<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">On Jan 4, 2020, at 7:37 PM, Ben Gamari <ben@well-typed.com> wrote:<br><br>Hi everyone,<br><br>I have recently been doing a fair amount of performance characterisation<br>and have long wanted a convenient means of collecting GHC runtime<br>statistics for later analysis. For this I quickly developed a small<br>wrapper utility [1].<br><br>To see what it does, let's consider an example. Say we made a change to<br>GHC which we believe might affect the runtime performance of Program.hs.<br>We could quickly check this by running,<br><br> $ ghc-before/_build/stage1/bin/ghc -O Program.hs<br> $ ghc_perf.py -o before.json ./Program<br> $ ghc-before/_build/stage1/bin/ghc -O Program.hs<br> $ ghc_perf.py -o after.json ./Program<br><br>This will produce two files, before.json and after.json, which contain<br>the various runtime statistics emitted by +RTS -s --machine-readable.<br>These files are in the same format as is used by my nofib branch [2] and<br>therefore can be compared using `nofib-compare` from that branch.<br><br>In addition to being able to collect runtime metrics, ghc_perf is also<br>able to collect performance counters (on Linux only) using perf. For<br>instance,<br><br> $ ghc_perf.py -o program.json \<br> -e instructions,cycles,cache-misses ./Program<br><br>will produce program.json containing not only RTS statistics but also<br>event counts from the perf instructions, cycles, and cache-misses<br>events. Alternatively, passing simply `ghc_perf.py --perf` enables a<br>reasonable default set of events (namely instructions, cycles,<br>cache-misses, branches, and branch-misses).<br><br>Finally, ghc_perf can also handle repeated runs. For instance,<br><br> $ ghc_perf.py -o program.json -r 5 --summarize \<br> -e instructions,cycles,cache-misses ./Program<br><br>will run Program 5 times, emit all of the collected samples to<br>program.json, and produce a (very basic) statistical summary of what it<br>collected on stdout.<br><br>Note that there are a few possible TODOs that I've been considering:<br><br>* I chose JSON as the output format to accomodate structured data (e.g.<br> capture experimental parameters in a structured way). However, in<br> practice this choice has lead to significantly more inconvenience<br> than I would like, especially given that so far I've only used the<br> format to capture basic key/value pairs. Perhaps reverting to CSV<br> would be preferable.<br><br>* It might be nice to also add support for cachegrind.<br><br>Anyways, I hope that others find this as useful as I have.<br><br>Cheers,<br><br>- Ben<br><br><br>[1] <a href="https://gitlab.haskell.org/bgamari/ghc-utils/blob/master/ghc_perf.py">https://gitlab.haskell.org/bgamari/ghc-utils/blob/master/ghc_perf.py</a><br>[2] <a href="https://gitlab.haskell.org/ghc/nofib/merge_requests/24">https://gitlab.haskell.org/ghc/nofib/merge_requests/24</a><hr>ghc-devs mailing list<br>ghc-devs@haskell.org<br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br></blockquote><br></pre></blockquote></div><br>-- <br>Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>