Resurrect ticky code for counting constructor arity
There is a dead piece of ticky profiling code that computes histograms of data constructor arities (including tuples) and size of vector returns. The function responsible is bumpHistogram
in [[GhcFile(compiler/codeGen/StgCmmTicky.hs)]], which masks the commented out function bumpHistogramE
. We can improve ticky profiling by resurrecting this dead code. There are following things that need to be done:
- Replace current no-op
bumpHistogram
withbumpHistogramE
. Note that current implementation ofbumpHistogramE
computes constructor arity at runtime. This is unnecessary because we know arity at compile time so we can avoid runtime check by doing sth like this:
bumpHistogram lbl n = do
let offset = n `min` 8
emit (addToMem cLong
(cmmIndexExpr cLongWidth
(CmmLit (CmmLabel (mkRtsDataLabel lbl)))
(CmmReg (CmmInt (fromIntegral offset) cLongWidth)))
1)
Note that mkRtsDataLabel
function does not exist anymore but we should be able to replace that call with mkCmmDataLabel rtsPackageId lbl
(speculation).
- We need to declare arrays that will store histogram values. Declarations of variables used for storing ticky statistics are in [[GhcFile(includes/stg/Ticky.h)]]. We also need to initialize the declared array to contain only zeros.
- Having declared the arrays we need to fix printing of computed arities. This is done in [[GhcFile(rts/Ticky.c)]]. Note that there is a lot of code that is commented out (
/* krc: comment out some of this stuff temporarily */
) or disabled with#if FALSE
pragma. We need to resurect *some* of it. There is aPR_HST
macro for printing one histogram entry. This seems bad. We should probably rework the part of code responsible for printing out results of historgams. - Current code counts arities from 0 to 8. Everything above 8 is put into the same bin as 8. This magical 8 is spread all over the code. We should declare a constant that is visible both in Haskell sources (see
bumpHistogram
in 1.) and RTS files and have all code behave properly depending on that constant - we should have loops instead of statically printing 9 elements of histogram array. - Some ticky functions that count arity histograms are not used. For example
tickyReturnNewCon
should probably be called bycgConApp
like this:
; emit =<< fcode_init
; tickyReturnNewCon
; emitReturn [idInfoToAmode idinfo] }
The above is a an outline, which should be fairly accurate, but unexpected things may show up along the way.
Trac metadata
Trac field | Value |
---|---|
Version | 7.7 |
Type | Task |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Profiling |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown/Multiple |
Architecture |