ghc-stack-profiler: RTS Callstack profiler for GHC.
RTS Callstack profiler for GHC.
The main idea is to periodically sample the Haskell callstack and use IPE and stack annotation information in order to understand the source locations which correspond to the stack frames. To profile a program it needs to be compiled and instrumented with the 'ghc-stack-profiler' package via:
import GHC.Stack.Profiler.Sampler main :: IO () main =withStackProfilerForMyThread(SampleIntervalMs10) $ do ...
This will spawn a profiling thread that will periodically take a snapshot of the current RTS callstack of your program and serialises it to the eventlog.
To improve readability of the profile, compile the program with -finfo-table-map and -fdistinct-constructor-tables.
Using cabal, this can be achieved with an appropriate cabal.project file:
packages: ...
...
package *
ghc-options: -finfo-table-map -fdistinct-constructor-tables
To emit the eventlog messages by the profiler, you need to run your program with the -l RTS flag, for example via:
./<program> ... +RTS -l -RTS
This will write out an eventlog to <program>.eventlog which can be transformed for speedscope.app via the script 'ghc-stack-profiler-speedscope'.
ghc-stack-profiler-speedscope <program>.eventlog
The resulting profile <program>.eventlog.json can be viewed and further analysed in speedscope.app.
Note that the results are affected by compilation optimisation options, such as -fno-omit-yields.
Modules
- Debug
- Trace
- Binary
- Debug.Trace.Binary.Compat
- Binary
- Trace
- GHC
- Internal
- ClosureTypes
- GHC.Internal.ClosureTypes.Compat
- Heap
- Closures
- GHC.Internal.Heap.Closures.Compat
- Closures
- InfoProv
- Types
- GHC.Internal.InfoProv.Types.Compat
- Types
- Stack
- Constants
- GHC.Internal.Stack.Constants.Compat
- Decode
- GHC.Internal.Stack.Decode.Compat
- Constants
- ClosureTypes
- Stack
- Annotation
- Experimental
- GHC.Stack.Annotation.Experimental.Compat
- Experimental
- Profiler
- GHC.Stack.Profiler.Decode
- GHC.Stack.Profiler.Sampler
- Stack
- GHC.Stack.Profiler.Stack.Compat
- GHC.Stack.Profiler.Stack.Decode
- GHC.Stack.Profiler.Util
- Annotation
- Internal
Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| use-ghc-trace-events | Use the package 'ghc-trace-events'. Disabling this flag makes it much easier to use | Enabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- ghc-stack-profiler-0.1.0.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
| Versions [RSS] | 0.1.0.0 |
|---|---|
| Change log | CHANGELOG.md |
| Dependencies | base (>=4.20 && <4.23), binary (>=0.8.9.3 && <0.11), bytestring (>=0.11 && <0.13), ghc-experimental (>=9.1400 && <9.1600), ghc-heap (>=9.10.1 && <9.16), ghc-internal (>=9.1001 && <9.1600), ghc-stack-profiler-core (>=0.1 && <0.2), ghc-trace-events (>=0.1.2.10 && <0.2), text (>=2 && <2.2) [details] |
| Tested with | ghc ==9.14 || ==9.12 || ==9.10 |
| License | BSD-3-Clause |
| Author | Hannes Siebenhandl, Wen Kokke, Matthew Pickering |
| Maintainer | hannes@well-typed.com |
| Category | Profiling, Benchmarking, Development |
| Uploaded | by fendor at 2025-12-10T08:25:23Z |
| Distributions | |
| Downloads | 1 total (1 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs not available [build log] All reported builds failed as of 2025-12-10 [all 2 reports] |