... | ... | @@ -14,11 +14,11 @@ You can't use cost-centre profiling and ticky-ticky profiling at the same time; |
|
|
|
|
|
Cost-center profiling in GHC, e.g. of SCCs, consists of the following components:
|
|
|
|
|
|
- Data-structures for representing cost-centres in [compiler/profiling/CostCentre.lhs](/trac/ghc/browser/ghc/compiler/profiling/CostCentre.lhs).
|
|
|
- Front-end support in [compiler/deSugar/DsExpr.lhs](/trac/ghc/browser/ghc/compiler/deSugar/DsExpr.lhs), for converting `SCC` pragma into the `Tick` constructor in Core.
|
|
|
- Modifications to optimization behavior in [compiler/coreSyn/CoreUtils.lhs](/trac/ghc/browser/ghc/compiler/coreSyn/CoreUtils.lhs) and [compiler/coreSyn/CorePrep.lhs](/trac/ghc/browser/ghc/compiler/coreSyn/CorePrep.lhs) to prevent optimizations which would result in misleading profile information. Most of this is to handle the fact that SCCs also count entries (tickishCounts, also applies to [Commentary/Hpc](commentary/hpc)); otherwise the only relevant optimization is avoiding floating expressions out of SCCs. Note that the simplifier also has "ticks" (so it can decide when to stop optimizing); these are not the same thing at all.
|
|
|
- Data-structures for representing cost-centres in [compiler/profiling/CostCentre.hs](/trac/ghc/browser/ghc/compiler/profiling/CostCentre.hs).
|
|
|
- Front-end support in [compiler/deSugar/DsExpr.hs](/trac/ghc/browser/ghc/compiler/deSugar/DsExpr.hs), for converting `SCC` pragma into the `Tick` constructor in Core.
|
|
|
- Modifications to optimization behavior in [compiler/coreSyn/CoreUtils.hs](/trac/ghc/browser/ghc/compiler/coreSyn/CoreUtils.hs) and [compiler/coreSyn/CorePrep.hs](/trac/ghc/browser/ghc/compiler/coreSyn/CorePrep.hs) to prevent optimizations which would result in misleading profile information. Most of this is to handle the fact that SCCs also count entries (tickishCounts, also applies to [Commentary/Hpc](commentary/hpc)); otherwise the only relevant optimization is avoiding floating expressions out of SCCs. Note that the simplifier also has "ticks" (so it can decide when to stop optimizing); these are not the same thing at all.
|
|
|
- The `StgSCC` constructor in STG, and code generation for it [compiler/codeGen/StgCmmProf.hs](/trac/ghc/browser/ghc/compiler/codeGen/StgCmmProf.hs)
|
|
|
- A pass over STG in [compiler/profiling/SCCfinal.lhs](/trac/ghc/browser/ghc/compiler/profiling/SCCfinal.lhs) to collect cost centres so that they can be statically declared by [compiler/profiling/ProfInit.hs](/trac/ghc/browser/ghc/compiler/profiling/ProfInit.hs), and add extra SCCs in the case of `-fprof-auto`; see also [compiler/profiling/NOTES](/trac/ghc/browser/ghc/compiler/profiling/NOTES)
|
|
|
- A pass over STG in [compiler/profiling/SCCfinal.hs](/trac/ghc/browser/ghc/compiler/profiling/SCCfinal.hs) to collect cost centres so that they can be statically declared by [compiler/profiling/ProfInit.hs](/trac/ghc/browser/ghc/compiler/profiling/ProfInit.hs), and add extra SCCs in the case of `-fprof-auto`; see also [compiler/profiling/NOTES](/trac/ghc/browser/ghc/compiler/profiling/NOTES)
|
|
|
- Code-generation for setting labels found in [compiler/codeGen/StgCmmProf.hs](/trac/ghc/browser/ghc/compiler/codeGen/StgCmmProf.hs), in particular saving and restoring CC labels and well as counting ticks; note that cost-centres even get their own constructor in C-- as CC_Labels (cost-centre labels).
|
|
|
- Runtime support for initializing and manipulating the actual runtime `CostCentre` structs which store information, in [rts/Profiling.c](/trac/ghc/browser/ghc/rts/Profiling.c); headers are located in [includes/rts/prof/CCS.h](/trac/ghc/browser/ghc/includes/rts/prof/CCS.h)
|
|
|
|
... | ... | |