diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-02-23 13:22:48 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-23 17:26:44 -0500 |
commit | a20433326eabd759502d9c170c3cc44ce6128a04 (patch) | |
tree | 72ba807d45f05460dcfad02d437d9b79c0518481 /rts/Profiling.c | |
parent | 0a77cedb914a67b8bd7c4af1f87714dc497fec3e (diff) | |
download | haskell-a20433326eabd759502d9c170c3cc44ce6128a04.tar.gz |
JSON profiler reports
This introduces a JSON output format for cost-centre profiler reports.
It's not clear whether this is really something we want to introduce
given that we may also move to a more Haskell-driven output pipeline in
the future, but I nevertheless found this helpful, so I thought I would
put it up.
Test Plan: Compile a program with `-prof -fprof-auto`; run with `+RTS
-pj`
Reviewers: austin, erikd, simonmar
Reviewed By: simonmar
Subscribers: duncan, maoe, thomie, simonmar
Differential Revision: https://phabricator.haskell.org/D3132
Diffstat (limited to 'rts/Profiling.c')
-rw-r--r-- | rts/Profiling.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/rts/Profiling.c b/rts/Profiling.c index b0019a48fc..0dc1e26f80 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -118,6 +118,7 @@ static CostCentreStack * isInIndexTable ( IndexTable *, CostCentre * ); static IndexTable * addToIndexTable ( IndexTable *, CostCentreStack *, CostCentre *, unsigned int ); static void ccsSetSelected ( CostCentreStack *ccs ); +static void aggregateCCCosts( CostCentreStack *ccs ); static void initTimeProfiling ( void ); static void initProfilingLogFile ( void ); @@ -694,10 +695,16 @@ reportCCSProfiling( void ) if (RtsFlags.CcFlags.doCostCentres == 0) return; ProfilerTotals totals = countTickss(CCS_MAIN); + aggregateCCCosts(CCS_MAIN); inheritCosts(CCS_MAIN); CostCentreStack *stack = pruneCCSTree(CCS_MAIN); sortCCSTree(stack); - writeCCSReport(prof_file, stack, totals); + + if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_JSON) { + writeCCSReportJson(prof_file, stack, totals); + } else { + writeCCSReport(prof_file, stack, totals); + } } /* ----------------------------------------------------------------------------- @@ -752,6 +759,21 @@ inheritCosts(CostCentreStack *ccs) return; } +static void +aggregateCCCosts( CostCentreStack *ccs ) +{ + IndexTable *i; + + ccs->cc->mem_alloc += ccs->mem_alloc; + ccs->cc->time_ticks += ccs->time_ticks; + + for (i = ccs->indexTable; i != 0; i = i->next) { + if (!i->back_edge) { + aggregateCCCosts(i->ccs); + } + } +} + // // Prune CCSs with zero entries, zero ticks or zero allocation from // the tree, unless COST_CENTRES_ALL is on. |