Analyze GHC .dump-timings files
Go to file
Tom McLaughlin 24f47838d8 Build
2024-02-13 21:09:02 -08:00
.github/workflows ci: try just building hledger 2024-02-13 20:24:51 -08:00
dist Build 2024-02-13 21:09:02 -08:00
scripts Parse systool events, closes #2 2021-08-02 10:42:51 -07:00
src Final fixes 2024-02-13 21:08:45 -08:00
.gitignore Do dev stuff out of dist-dev 2024-02-13 03:34:44 -08:00
CHANGELOG.md Update README.md and add CHANGELOG.md 2024-02-05 19:15:43 -08:00
default.nix Update nix dependencies 2021-08-02 11:00:05 -07:00
hledger.png Add instructions and another image 2021-08-01 04:04:24 -07:00
hledger.svg Add README + image 2021-08-01 03:55:45 -07:00
LICENSE Create LICENSE 2021-10-08 18:27:13 -06:00
package-lock.json Looking good, just a couple breadcrumb glitches to fix 2024-02-13 02:34:29 -08:00
package.json Do dev stuff out of dist-dev 2024-02-13 03:34:44 -08:00
pinned-nixpkgs.nix Add nix derivation 2021-08-01 02:54:54 -07:00
README.md readme: "cabal build" -> "cabal build all" 2024-02-13 20:24:40 -08:00
time-ghc-modules Make configurable PROCESS_SCRIPT and HTML_FILE env variables 2021-10-07 23:20:13 -06:00
time-ghc-modules-nix Update nix dependencies 2021-08-02 11:00:05 -07:00
tsconfig.json Progress on treemap 2024-02-03 03:24:53 -08:00

time-ghc-modules

Figure out why your builds are slow. This tool analyzes how long it takes GHC to compile your Haskell modules, broken down by phase.

Quick start

cd <my-project>

stack clean
stack build --ghc-options "-ddump-to-file -ddump-timings"
# ----- OR -----
cabal clean
cabal build all --ghc-options "-ddump-to-file -ddump-timings"

If you have Nix, you can simply run time-ghc-modules from Nixpkgs!

nix run nixpkgs#time-ghc-modules

Or, clone the repo first:

git clone git@github.com:codedownio/time-ghc-modules.git /path/to/time-ghc-modules

# If you have Nix, you can use the fully reproducible version
/path/to/time-ghc-modules/time-ghc-modules-nix

# Otherwise, your system needs to have SQLite >= 3.33.0, Python 3, and sed
/path/to/time-ghc-modules/time-ghc-modules

The script will search for all your *.dump-timings files and analyze them. It will finish by printing out the path to an HTML file:

...
--> Wrote report at file:///tmp/tmp.pvnp4FYmLa/report.html

Example: hledger

You can generate the time report below for hledger by running the following commands (assuming you have Nix).

set -e
cd $(mktemp -d)
git clone git@github.com:simonmichael/hledger.git
git clone git@github.com:codedownio/time-ghc-modules.git
cd hledger
stack build --ghc-options "-ddump-to-file -ddump-timings"
../time-ghc-modules/time-ghc-modules-nix

hledger profile

Tips

  • The script will output its log messages to stderr and print the final report path to stdout (assuming it didn't exit with a failure). This makes it easy to use the output in scripts. For example:
# Build the report and open it in your browser
> firefox $(/path/to/time-ghc-modules/time-ghc-modules)
# Build the report in CI and stash it somewhere
> cp $(/path/to/time-ghc-modules/time-ghc-modules) $MY_CI_ARTIFACTS_DIR/
  • You can also look at the timing of individual components, but doing e.g. stack build some-component:lib. But, make sure to clean up any old .dump-timings files from previous runs:
find . -name "*.dump-timings" | xargs rm
  • GHC's -dumpdir option can be used to consolidate the .dump-timings files, so they aren't left all over your source tree. For example:
stack build --ghc-options "-ddump-to-file -ddump-timings -dumpdir .ghcdump"

Compatibility

The flag -ddump-timings is available for GHC >= 8.4.1.