# endif
\end{code}
-The current cost centre. It is initially set to "MAIN" by main.
-We have to be careful when doing so, as an initial @SET_CCC(CC_MAIN)@
-would try to increment some @sub_scc_count@ of the @CCC@ (nothing!).
-
\begin{code}
CostCentre CCC; /* _not_ initialised */
\begin{code}
#if defined(PROFILING)
-CC_DECLARE(CC_OVERHEAD, "OVERHEAD_of", "PROFILING", "MAIN", CC_IS_CAF,/*not static*/);
-CC_DECLARE(CC_SUBSUMED, "SUBSUMED", "MAIN", "MAIN", CC_IS_SUBSUMED,/*not static*/);
-CC_DECLARE(CC_DONTZuCARE,"DONT_CARE", "MAIN", "MAIN", CC_IS_BORING,/*not static*/);
+CC_DECLARE(CC_OVERHEAD, "OVERHEAD_of", "PROFILING", "PROFILING", CC_IS_CAF, /*not static*/);
+CC_DECLARE(CC_SUBSUMED, "SUBSUMED", "MAIN", "MAIN", CC_IS_SUBSUMED, /*not static*/);
+CC_DECLARE(CC_DONTZuCARE,"DONT_CARE", "MAIN", "MAIN", CC_IS_BORING, /*not static*/);
#endif
\end{code}
char *rts_argv[], *prog_argv[];
{
I_ arg, ch;
-#ifndef PAR
- char *select_cc = 0;
- char *select_mod = 0;
- char *select_grp = 0;
- char *select_descr = 0;
- char *select_type = 0;
- char *select_kind = 0;
- char *left, *right;
-#endif
prog_argv_save = prog_argv;
rts_argv_save = rts_argv;
}
#if defined(PROFILING)
- if (heap_profile_init(select_cc, select_mod, select_grp,
- select_descr, select_type, select_kind,
- prog_argv))
+ if (heap_profile_init(prog_argv))
return 1;
#endif
REGISTER_CC(CC_DONTZuCARE); /* register cost centre CC_DONT_CARE Right??? ToDo */
#endif
- /* as per SET_CCC macro, without the sub_scc_count++ bit */
- CCC = (CostCentre)STATIC_CC_REF(CC_MAIN);
- CCC->scc_count++;
+ SET_CCC_RTS(CC_MAIN,0,1); /* without the sub_scc_count++ */
#if defined(PROFILING)
/* always register -- if we do not, we get warnings (WDP 94/12) */
# endif /* PROFILING */
}
+rtsBool
+have_interesting_groups(CostCentre cc)
+{
+ char* interesting_group = NULL;
+
+ for (; cc != REGISTERED_END; cc = cc->registered) {
+ if (! cc_to_ignore(cc) && strcmp(cc->module,cc->group) != 0) {
+ if (interesting_group && strcmp(cc->group, interesting_group) != 0) {
+ return(rtsTrue);
+ } else {
+ interesting_group = cc->group;
+ }
+ }
+ }
+ return(rtsFalse);
+}
+
void
report_cc_profiling(final)
I_ final;
CostCentre cc;
I_ count;
char temp[128]; /* sigh: magic constant */
- W_ total_ticks = 0, total_alloc = 0, total_allocs = 0;
- W_ ignored_ticks = 0, ignored_alloc = 0, ignored_allocs = 0;
+ W_ total_ticks, ignored_ticks;
+ W_ total_alloc = 0, total_allocs = 0;
+ rtsBool do_groups = rtsFalse;
#ifdef PAR
- I_ final_ticks = 0; /*No. ticks in last sample*/
+ I_ final_ticks; /*No. ticks in last sample*/
#endif
if (!RTSflags.CcFlags.doCostCentres)
return;
blockVtAlrmSignal();
+ /* To avoid inconsistency, initialise the tick variables
+ after having blocked out VTALRM */
+ total_ticks = 0;
+ ignored_ticks = 0;
+#ifdef PAR
+ final_ticks = 0;
+#endif
if (serial_file) {
StgFloat seconds = (previous_ticks + current_ticks) / (StgFloat) TICK_FREQUENCY;
if ( cc_to_ignore(cc) ) { /* reporting these just confuses users... */
ignored_ticks += cc->prev_ticks;
- ignored_alloc += cc->mem_alloc;
- ignored_allocs += cc->mem_allocs;
} else {
total_ticks += cc->prev_ticks;
total_alloc += cc->mem_alloc;
+#if defined(PROFILING_DETAIL_COUNTS)
total_allocs += cc->mem_allocs;
+#endif
}
}
fprintf(prof_file, " %s", prog_argv_save[count]);
fprintf(prof_file, "\n\n");
+
fprintf(prof_file, "\ttotal time = %11.2f secs (%lu ticks @ %d ms)\n",
- total_ticks / (StgFloat) TICK_FREQUENCY, total_ticks, TICK_MILLISECS);
- fprintf(prof_file, "\ttotal alloc = %11s bytes (%lu closures) (excludes profiling overheads)\n",
- ullong_format_string((ullong) total_alloc * sizeof(W_), temp, rtsTrue/*commas*/), total_allocs);
+ total_ticks / (StgFloat) TICK_FREQUENCY, total_ticks, TICK_MILLISECS);
+ fprintf(prof_file, "\ttotal alloc = %11s bytes",
+ ullong_format_string((ullong) total_alloc * sizeof(W_), temp, rtsTrue/*commas*/));
/* ToDo: 64-bit error! */
- fprintf(prof_file, "\n");
+
+#if defined(PROFILING_DETAIL_COUNTS)
+ fprintf(prof_file, " (%lu closures)", total_allocs);
+#endif
+ fprintf(prof_file, " (excludes profiling overheads)\n\n");
+
fprintf(prof_file, "%-16.16s %-11.11s", "COST CENTRE", "MODULE");
-/* ToDo:group
- fprintf(prof_file, " %-11.11s", "GROUP");
-*/
- fprintf(prof_file, " %5s %5s %6s %6s", "scc", "subcc", "%time", "%alloc");
- if (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE)
- fprintf(prof_file, " %11s %13s %8s %8s %8s (%5s %8s)", "cafcc", "thunks", "funcs", "PAPs", "closures", "ticks", "bytes");
+ do_groups = have_interesting_groups(Registered_CC);
+ if (do_groups) fprintf(prof_file, " %-11.11s", "GROUP");
+
+ fprintf(prof_file, "%8s %6s %6s %8s %5s %5s", "scc", "%time", "%alloc", "inner", "cafs", "dicts");
+
+ if (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
+ fprintf(prof_file, " %5s %9s", "ticks", "bytes");
+#if defined(PROFILING_DETAIL_COUNTS)
+ fprintf(prof_file, " %8s %8s %8s %8s %8s %8s %8s",
+ "closures", "thunks", "funcs", "PAPs", "subfuns", "subcafs", "cafssub");
+#endif
+ }
fprintf(prof_file, "\n\n");
for (cc = Registered_CC; cc != REGISTERED_END; cc = cc->registered) {
if ( (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_ALL
/* force printing of *all* cost centres if -P -P */ )
- || ( ! cc_to_ignore(cc)
- && (cc->scc_count || cc->sub_scc_count || cc->prev_ticks || cc->mem_alloc
- || (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE
- && (cc->thunk_count || cc->function_count || cc->pap_count
- || cc->cafcc_count || cc->sub_cafcc_count))))
- ) {
-
+ || ( ! cc_to_ignore(cc)
+ && (cc->scc_count || cc->sub_scc_count || cc->prev_ticks || cc->mem_alloc
+ || (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE
+ && (cc->sub_cafcc_count || cc->sub_dictcc_count
+#if defined(PROFILING_DETAIL_COUNTS)
+ || cc->thunk_count || cc->function_count || cc->pap_count
+#endif
+ ))))) {
fprintf(prof_file, "%-16.16s %-11.11s", cc->label, cc->module);
-/* ToDo:group
- fprintf(prof_file, " %-11.11s",cc->group);
-*/
- fprintf(prof_file, " %5ld %5ld %5.1f %5.1f",
- cc->scc_count, cc->sub_scc_count,
- total_ticks == 0 ? 0.0 : (cc->prev_ticks / (StgFloat) total_ticks * 100),
- total_alloc == 0 ? 0.0 : (cc->mem_alloc / (StgFloat) total_alloc * 100));
-
- if (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE)
- fprintf(prof_file, " %8ld %-8ld %8ld %8ld %8ld %8ld (%5ld %8ld)",
- cc->cafcc_count, cc->sub_cafcc_count,
- cc->thunk_count, cc->function_count, cc->pap_count,
- cc->mem_allocs,
- cc->prev_ticks, cc->mem_alloc*sizeof(W_));
+ if (do_groups) fprintf(prof_file, " %-11.11s",cc->group);
+
+ fprintf(prof_file, "%8ld %5.1f %5.1f %8ld %5ld %5ld",
+ cc->scc_count,
+ total_ticks == 0 ? 0.0 : (cc->prev_ticks / (StgFloat) total_ticks * 100),
+ total_alloc == 0 ? 0.0 : (cc->mem_alloc / (StgFloat) total_alloc * 100),
+ cc->sub_scc_count, cc->sub_cafcc_count, cc->sub_dictcc_count);
+
+ if (RTSflags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
+ fprintf(prof_file, " %5ld %9ld", cc->prev_ticks, cc->mem_alloc*sizeof(W_));
+#if defined(PROFILING_DETAIL_COUNTS)
+ fprintf(prof_file, " %8ld %8ld %8ld %8ld %8ld %8ld %8ld",
+ cc->mem_allocs, cc->thunk_count,
+ cc->function_count, cc->pap_count,
+ cc->subsumed_fun_count, cc->subsumed_caf_count,
+ cc->caffun_subsumed);
+#endif
+ }
fprintf(prof_file, "\n");
}
}
else if (cc1->mem_alloc < cc2->mem_alloc) /* time equal; alloc less */
return 0;
- if (cc1->thunk_count > cc2->thunk_count) /* time & alloc equal: cmp enters */
- return 1;
- else if (cc1->thunk_count < cc2->thunk_count)
- return 0;
-
return (cc_lt_label(cc1, cc2)); /* all data equal: cmp labels */
}
else if (cc1->prev_ticks < cc2->prev_ticks) /* alloc equal; time less */
return 0;
- if (cc1->thunk_count > cc2->thunk_count) /* alloc & time: cmp enters */
- return 1;
- else if (cc1->thunk_count < cc2->thunk_count)
- return 0;
-
return (cc_lt_label(cc1, cc2)); /* all data equal: cmp labels */
}