I love GHC's profiling support, and like to use it to analyze the performance of my Haskell applications. However, profiling an application is difficult when it depends on any third-party libraries, as cabal doesn't include profiling information by default.
Fortunately, cabal can reinstall a library with profiling support, with:
cabal install --reinstall -p <library>
Unfortunately, cabal is a bit of a simpleton, so this will fail unless that libraries dependencies are also installed with profiling enabled:
cabal install --reinstall -p <libraryX> <libraryY> <libraryZ> ...
For example, a user who wants to profile his die-rolling program must run:
$ sudo apt-get install haskell-platform haskell-platform-doc haskell-platform-prof
$ sudo cabal install --reinstall -p mwc-random rvar random-fu random-source mersenne-random-pure64 stateref flexible-defaults th-extras MonadPrompt math-functions erf vector-th-unbox monad-loops random-shuffle MonadRandom
And that long list of packages must be slowly grown one at a time, starting from random-source, based on many attempts at running cabal install --reinstall -p ..., waiting several minutes for compilation to partially complete, and scrolling back up through the logs to track down which dependencies also neglected to compile with profiling enabled.
It can take a while to get a list of this long, full dependency chain. It would be much easier if cabal simply enabled `-p` by default, so we didn't have to think about it.
What do you think?
--
Cheers,
Andrew Pennebaker