... | ... | @@ -24,8 +24,6 @@ Cost-center profiling in GHC, e.g. of SCCs, consists of the following components |
|
|
|
|
|
## Ticky-ticky profiling
|
|
|
|
|
|
### Using ticky-ticky profiling
|
|
|
|
|
|
|
|
|
Ticky-ticky profiling is very simple (conceptually): instrument the C code generated by GHC with a lot of extra code that updates counters when various (supposedly) interesting things happen, and generate a report giving the values of the counters when your program terminates. GHC does this instrumentation for you when you compile your program with a special flag. Then, you use another flag to tell the RTS to generate the profiling report.
|
|
|
|
... | ... | @@ -40,40 +38,4 @@ You might want to use ticky-ticky profiling for one of the following two reasons |
|
|
I won't necessarily try to argue that ticky-ticky is useful at all for the second group of people, but it's better than nothing, and perhaps the ticky-ticky data could be used to build a better profiler.
|
|
|
|
|
|
|
|
|
To use ticky-ticky, first you need to do:
|
|
|
|
|
|
```wiki
|
|
|
make way=t
|
|
|
```
|
|
|
|
|
|
|
|
|
in the `rts/` subdirectory in your GHC tree. This will build a version of the RTS library that has all the necessary instrumentation code.
|
|
|
|
|
|
|
|
|
Then, compile the code you want to profile with the `-fticky-ticky` flag.
|
|
|
|
|
|
|
|
|
Finally, run your executable with:
|
|
|
|
|
|
```wiki
|
|
|
+RTS -rfoo.ticky -RTS
|
|
|
```
|
|
|
|
|
|
|
|
|
and this will generate a file called `foo.ticky` (or whatever you want) in the current directory containing the ticky-ticky profiling data: i.e., the values of various counters, and some summary data.
|
|
|
|
|
|
|
|
|
If some of the counters are zero when they shouldn't be, that means they're not implemented yet (for example, probably nothing having to do with counting allocations is working). If you want them to be, complain on the ghc-users mailing list. Counters for function entries, if nothing else, should be working.
|
|
|
|
|
|
TODO document what the counters mean.
|
|
|
|
|
|
### Implementation notes
|
|
|
|
|
|
|
|
|
When compiling with `-fticky-ticky` on, the back-end generates calls to a bunch of C-- macros that update the ticky counters. The relevant compiler code is mostly in [compiler/codeGen/CgTicky.hs](/trac/ghc/browser/ghc/compiler/codeGen/CgTicky.hs).
|
|
|
|
|
|
|
|
|
Those macros are defined in [includes/Cmm.h](/trac/ghc/browser/ghc/includes/Cmm.h). Most of them (probably all of them, at the moment) just increment counters (variables in C) that are declared in [includes/TickyCounters.h](/trac/ghc/browser/ghc/includes/TickyCounters.h). The latter file is likely to get out of sync with the former, so it really should be automatically generated.
|
|
|
|
|
|
|
|
|
The code in the RTS that prints out the ticky report is in [rts/Ticky.c](/trac/ghc/browser/ghc/rts/Ticky.c) |
|
|
\ No newline at end of file |
|
|
For more info, including HOWTO details, see [Debugging/TickyTicky](debugging/ticky-ticky). |