Changes between Version 17 and Version 18 of Commentary/Profiling


Ignore:
Timestamp:
Mar 29, 2013 3:29:01 PM (2 years ago)
Author:
nfrisby
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Profiling

    v17 v18  
    2121== Ticky-ticky profiling ==
    2222
    23 === Using ticky-ticky profiling ===
    24 
    2523Ticky-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.
    2624
     
    3331I 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.
    3432
    35 To use ticky-ticky, first you need to do:
    36 {{{
    37 make way=t
    38 }}}
    39 in the {{{rts/}}} subdirectory in your GHC tree. This will build a version of the RTS library that has all the necessary instrumentation code.
    40 
    41 Then, compile the code you want to profile with the {{{-fticky-ticky}}} flag.
    42 
    43 Finally, run your executable with:
    44 {{{
    45 +RTS -rfoo.ticky -RTS
    46 }}}
    47 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.
    48 
    49 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.
    50 
    51 TODO: document what the counters mean.
    52 
    53 === Implementation notes ===
    54 
    55 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 [[GhcFile(compiler/codeGen/CgTicky.hs)]].
    56 
    57 Those macros are defined in [[GhcFile(includes/Cmm.h)]]. Most of them (probably all of them, at the moment) just increment counters (variables in C) that are declared in [[GhcFile(includes/TickyCounters.h)]]. The latter file is likely to get out of sync with the former, so it really should be automatically generated.
    58 
    59 The code in the RTS that prints out the ticky report is in [[GhcFile(rts/Ticky.c)]]
     33For more info, including HOWTO details, see [wiki:Debugging/TickyTicky].