EventLog: Factor out ensureRoomFor*Event
[ghc.git] / rts / Ticky.c
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The AQUA project, Glasgow University, 1992-1997
4 * (c) The GHC Team, 1998-1999
5 *
6 * Ticky-ticky profiling
7 *-------------------------------------------------------------------------- */
8
9 #define TICKY_C /* define those variables */
10 #include "PosixSource.h"
11 #include "Rts.h"
12
13 /* Catch-all top-level counter struct. Allocations from CAFs will go
14 * here.
15 */
16 StgEntCounter top_ct
17 = { 0, 0, 0,
18 "TOP", "",
19 0, 0, NULL };
20
21 /* Data structure used in ``registering'' one of these counters. */
22
23 StgEntCounter *ticky_entry_ctrs = NULL; /* root of list of them */
24
25 /* We want Haskell code compiled with -ticky to be linkable with any
26 * version of the RTS, so we have to make sure all the symbols that
27 * ticky-compiled code may refer to are defined by every RTS. (#3439)
28 * Hence the #ifdef is here, rather than up above.
29 */
30 #if defined(TICKY_TICKY)
31
32 #include "Ticky.h"
33
34 /* -----------------------------------------------------------------------------
35 Print out all the counters
36 -------------------------------------------------------------------------- */
37
38 static void printRegisteredCounterInfo (FILE *); /* fwd decl */
39
40 #define INTAVG(a,b) ((b == 0) ? 0.0 : ((double) (a) / (double) (b)))
41 #define PC(a) (100.0 * a)
42
43 #define AVG(thing) \
44 StgDouble avg##thing = INTAVG(tot##thing,ctr##thing)
45
46 void
47 PrintTickyInfo(void)
48 {
49 // XXX This is only used in commented out or #if FALSE'd out code currently:
50 // unsigned long i;
51
52 /* XXX These are used only in an #if FALSE block below */
53 #if FALSE
54 unsigned long tot_allocs = /* total number of things allocated */
55 ALLOC_FUN_ctr + ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr + ALLOC_CON_ctr + ALLOC_TUP_ctr +
56 + ALLOC_TSO_ctr + ALLOC_BH_ctr + ALLOC_PAP_ctr + ALLOC_PRIM_ctr
57 ;
58
59 unsigned long tot_adm_wds = /* total number of admin words allocated */
60 ALLOC_FUN_adm + ALLOC_THK_adm + ALLOC_CON_adm + ALLOC_TUP_adm
61 + ALLOC_TSO_adm + ALLOC_BH_adm + ALLOC_PAP_adm + ALLOC_PRIM_adm
62 ;
63
64 unsigned long tot_gds_wds = /* total number of words of ``good stuff'' allocated */
65 ALLOC_FUN_gds + ALLOC_THK_gds + ALLOC_CON_gds + ALLOC_TUP_gds
66 + ALLOC_TSO_gds + ALLOC_BH_gds + ALLOC_PAP_gds + ALLOC_PRIM_gds
67 ;
68
69 unsigned long tot_slp_wds = /* total number of ``slop'' words allocated */
70 ALLOC_FUN_slp + ALLOC_THK_slp + ALLOC_CON_slp + ALLOC_TUP_slp
71 + ALLOC_TSO_slp + ALLOC_BH_slp + ALLOC_PAP_slp + ALLOC_PRIM_slp
72 ;
73
74 unsigned long tot_wds = /* total words */
75 tot_adm_wds + tot_gds_wds + tot_slp_wds;
76 #endif
77
78 unsigned long tot_thk_enters = ENT_STATIC_THK_MANY_ctr + ENT_DYN_THK_MANY_ctr
79 + ENT_STATIC_THK_SINGLE_ctr + ENT_DYN_THK_SINGLE_ctr;
80 unsigned long tot_con_enters = ENT_STATIC_CON_ctr + ENT_DYN_CON_ctr;
81
82 unsigned long tot_fun_direct_enters = ENT_STATIC_FUN_DIRECT_ctr + ENT_DYN_FUN_DIRECT_ctr;
83 unsigned long tot_ind_enters = ENT_STATIC_IND_ctr + ENT_DYN_IND_ctr;
84
85 // This is the number of times we entered a function via some kind
86 // of slow call. It amounts to all the slow applications, not
87 // counting those that were to too few arguments.
88 /*
89 XXX This us unused - can we delete it? -- IGL 2008-04-25
90 unsigned long tot_fun_slow_enters =
91 SLOW_CALL_ctr -
92 SLOW_CALL_FUN_TOO_FEW_ctr -
93 SLOW_CALL_PAP_TOO_FEW_ctr;
94 */
95
96 unsigned long tot_known_calls =
97 KNOWN_CALL_ctr + KNOWN_CALL_TOO_FEW_ARGS_ctr +
98 + KNOWN_CALL_EXTRA_ARGS_ctr;
99 unsigned long tot_tail_calls =
100 UNKNOWN_CALL_ctr + tot_known_calls;
101
102 unsigned long tot_enters =
103 tot_con_enters + tot_fun_direct_enters +
104 tot_ind_enters + ENT_PERM_IND_ctr + ENT_PAP_ctr + tot_thk_enters;
105 unsigned long jump_direct_enters =
106 tot_enters - ENT_VIA_NODE_ctr;
107
108
109 unsigned long tot_returns =
110 RET_NEW_ctr + RET_OLD_ctr + RET_UNBOXED_TUP_ctr;
111
112 unsigned long tot_returns_of_new = RET_NEW_ctr;
113
114 unsigned long con_updates = UPD_CON_IN_NEW_ctr + UPD_CON_IN_PLACE_ctr;
115 unsigned long pap_updates = UPD_PAP_IN_NEW_ctr + UPD_PAP_IN_PLACE_ctr;
116
117 unsigned long tot_updates = UPD_SQUEEZED_ctr + pap_updates + con_updates;
118
119 unsigned long tot_new_updates = UPD_NEW_IND_ctr + UPD_NEW_PERM_IND_ctr;
120 unsigned long tot_old_updates = UPD_OLD_IND_ctr + UPD_OLD_PERM_IND_ctr;
121 unsigned long tot_gengc_updates = tot_new_updates + tot_old_updates;
122
123 FILE *tf = RtsFlags.TickyFlags.tickyFile;
124
125 /* If tf = NULL, that means the user passed in stderr for the ticky stats
126 file. According to a comment in RtsFlags.c, this means to use
127 debugBelch to print out messages. But this function prints out a lot
128 of stuff so in order to avoid changing a lot of code, we just dump
129 the same output to stderr (for now). */
130 if( tf == NULL )
131 tf = stderr;
132
133 /* krc: avoid dealing with this just now */
134 #if FALSE
135 fprintf(tf,"\n\nALLOCATIONS: %ld (%ld words total: %ld admin, %ld goods, %ld slop)\n",
136 tot_allocs, tot_wds, tot_adm_wds, tot_gds_wds, tot_slp_wds);
137 fprintf(tf,"\t\t\t\ttotal words:\t 2 3 4 5 6+\n");
138
139 #define ALLOC_HISTO_MAGIC(categ) \
140 (PC(INTAVG(ALLOC_##categ##_hst[0], ALLOC_##categ##_ctr))), \
141 (PC(INTAVG(ALLOC_##categ##_hst[1], ALLOC_##categ##_ctr))), \
142 (PC(INTAVG(ALLOC_##categ##_hst[2], ALLOC_##categ##_ctr))), \
143 (PC(INTAVG(ALLOC_##categ##_hst[3], ALLOC_##categ##_ctr))), \
144 (PC(INTAVG(ALLOC_##categ##_hst[4], ALLOC_##categ##_ctr)))
145
146 fprintf(tf,"%11ld (%5.1f%%) function values",
147 ALLOC_FUN_ctr,
148 PC(INTAVG(ALLOC_FUN_ctr, tot_allocs)));
149 if (ALLOC_FUN_ctr != 0)
150 fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FUN));
151
152
153 fprintf(tf,"\n%11ld (%5.1f%%) thunks",
154 ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr,
155 PC(INTAVG(ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr, tot_allocs)));
156
157 #define ALLOC_THK_ctr (ALLOC_UP_THK_ctr + ALLOC_SE_THK_ctr)
158 /* hack to make ALLOC_HISTO_MAGIC still work for THK */
159 if ((ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr) != 0)
160 fprintf(tf,"\t\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(THK));
161 #undef ALLOC_THK_ctr
162
163 fprintf(tf,"\n%11ld (%5.1f%%) data values",
164 ALLOC_CON_ctr,
165 PC(INTAVG(ALLOC_CON_ctr, tot_allocs)));
166 if (ALLOC_CON_ctr != 0)
167 fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(CON));
168
169 fprintf(tf,"\n%11ld (%5.1f%%) big tuples",
170 ALLOC_TUP_ctr,
171 PC(INTAVG(ALLOC_TUP_ctr, tot_allocs)));
172 if (ALLOC_TUP_ctr != 0)
173 fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TUP));
174
175 fprintf(tf,"\n%11ld (%5.1f%%) black holes",
176 ALLOC_BH_ctr,
177 PC(INTAVG(ALLOC_BH_ctr, tot_allocs)));
178 if (ALLOC_BH_ctr != 0)
179 fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(BH));
180
181 fprintf(tf,"\n%11ld (%5.1f%%) prim things",
182 ALLOC_PRIM_ctr,
183 PC(INTAVG(ALLOC_PRIM_ctr, tot_allocs)));
184 if (ALLOC_PRIM_ctr != 0)
185 fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PRIM));
186
187 fprintf(tf,"\n%11ld (%5.1f%%) partial applications",
188 ALLOC_PAP_ctr,
189 PC(INTAVG(ALLOC_PAP_ctr, tot_allocs)));
190 if (ALLOC_PAP_ctr != 0)
191 fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PAP));
192
193 fprintf(tf,"\n%11ld (%5.1f%%) thread state objects",
194 ALLOC_TSO_ctr,
195 PC(INTAVG(ALLOC_TSO_ctr, tot_allocs)));
196 if (ALLOC_TSO_ctr != 0)
197 fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TSO));
198
199 fprintf(tf,"\n");
200
201 fprintf(tf,"\nTotal storage-manager allocations: %ld (%ld words)\n\t[%ld words lost to speculative heap-checks]\n", ALLOC_HEAP_ctr, ALLOC_HEAP_tot, ALLOC_HEAP_tot - tot_wds);
202 #endif /* FALSE */
203
204
205 fprintf(tf,"\nSTACK USAGE:\n"); /* NB: some bits are direction sensitive */
206
207
208 fprintf(tf,"\nENTERS: %ld of which %ld (%.1f%%) direct to the entry code\n\t\t [the rest indirected via Node's info ptr]\n",
209 tot_enters,
210 jump_direct_enters,
211 PC(INTAVG(jump_direct_enters,tot_enters)));
212 fprintf(tf,"%11ld (%5.1f%%) thunks\n",
213 tot_thk_enters,
214 PC(INTAVG(tot_thk_enters,tot_enters)));
215 fprintf(tf,"%11ld (%5.1f%%) data values\n",
216 tot_con_enters,
217 PC(INTAVG(tot_con_enters,tot_enters)));
218 fprintf(tf,"%11ld (%5.1f%%) normal indirections\n",
219 tot_ind_enters,
220 PC(INTAVG(tot_ind_enters,tot_enters)));
221 fprintf(tf,"%11" FMT_Int " (%5.1f%%) permanent indirections\n",
222 ENT_PERM_IND_ctr,
223 PC(INTAVG(ENT_PERM_IND_ctr,tot_enters)));
224
225
226 fprintf(tf,"\nFUNCTION ENTRIES: %ld\n", tot_fun_direct_enters);
227
228 fprintf(tf, "\nTAIL CALLS: %ld, of which %ld (%.lf%%) were to known functions\n",
229 tot_tail_calls, tot_known_calls,
230 PC(INTAVG(tot_known_calls,tot_tail_calls)));
231
232 fprintf(tf, "\nSLOW APPLICATIONS: %" FMT_Int " evaluated, %" FMT_Int " unevaluated\n",
233 SLOW_CALL_ctr, SLOW_CALL_UNEVALD_ctr);
234 fprintf(tf, "\n");
235 fprintf(tf, " Too few args Correct args Too many args\n");
236 fprintf(tf, " FUN %8" FMT_Int " %8" FMT_Int " %8" FMT_Int "\n",
237 SLOW_CALL_FUN_TOO_FEW_ctr, SLOW_CALL_FUN_CORRECT_ctr, SLOW_CALL_FUN_TOO_MANY_ctr);
238 fprintf(tf, " PAP %8" FMT_Int " %8" FMT_Int " %8" FMT_Int "\n",
239 SLOW_CALL_PAP_TOO_FEW_ctr, SLOW_CALL_PAP_CORRECT_ctr, SLOW_CALL_PAP_TOO_MANY_ctr);
240 fprintf(tf, "\n");
241
242 fprintf(tf,"\nRETURNS: %ld\n", tot_returns);
243 fprintf(tf,"%11ld (%5.1f%%) from entering a new constructor\n\t\t [the rest from entering an existing constructor]\n",
244 tot_returns_of_new,
245 PC(INTAVG(tot_returns_of_new,tot_returns)));
246
247 /* krc: comment out some of this stuff temporarily */
248
249 /*
250 fprintf(tf, "\nRET_NEW: %11ld: ", RET_NEW_ctr);
251 for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
252 PC(INTAVG(RET_NEW_hst[i],RET_NEW_ctr))); }
253 fprintf(tf, "\n");
254 fprintf(tf, "RET_OLD: %11ld: ", RET_OLD_ctr);
255 for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
256 PC(INTAVG(RET_OLD_hst[i],RET_OLD_ctr))); }
257 fprintf(tf, "\n");
258 fprintf(tf, "RET_UNBOXED_TUP: %11ld: ", RET_UNBOXED_TUP_ctr);
259 for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
260 PC(INTAVG(RET_UNBOXED_TUP_hst[i],
261 RET_UNBOXED_TUP_ctr))); }
262 fprintf(tf, "\n");
263 */
264
265 fprintf(tf,"\nUPDATE FRAMES: %" FMT_Int " (%" FMT_Int " omitted from thunks)",
266 UPDF_PUSHED_ctr,
267 UPDF_OMITTED_ctr);
268
269 fprintf(tf,"\nCATCH FRAMES: %" FMT_Int "", CATCHF_PUSHED_ctr);
270
271 if (UPDF_RCC_PUSHED_ctr != 0)
272 fprintf(tf,"%11" FMT_Int " restore cost centre frames (%" FMT_Int " omitted)\n",
273 UPDF_RCC_PUSHED_ctr,
274 UPDF_RCC_OMITTED_ctr);
275
276 fprintf(tf,"\nUPDATES: %ld\n", tot_updates);
277 fprintf(tf,"%11ld (%5.1f%%) data values\n\t\t [%" FMT_Int " in place, %" FMT_Int " allocated new space]\n",
278 con_updates,
279 PC(INTAVG(con_updates,tot_updates)),
280 UPD_CON_IN_PLACE_ctr, UPD_CON_IN_NEW_ctr);
281 fprintf(tf,"%11ld (%5.1f%%) partial applications\n\t\t [%" FMT_Int " in place, %" FMT_Int " allocated new space]\n",
282 pap_updates,
283 PC(INTAVG(pap_updates,tot_updates)),
284 UPD_PAP_IN_PLACE_ctr, UPD_PAP_IN_NEW_ctr);
285 fprintf(tf,"%11" FMT_Int " (%5.1f%%) updates by squeezing\n",
286 UPD_SQUEEZED_ctr,
287 PC(INTAVG(UPD_SQUEEZED_ctr, tot_updates)));
288
289 /* krc: also avoid dealing with this for now */
290 #if FALSE
291 fprintf(tf, "\nUPD_CON_IN_NEW: %11ld: ", UPD_CON_IN_NEW_ctr);
292 for (i = 0; i < 9; i++) { fprintf(tf, "%11ld", UPD_CON_IN_NEW_hst[i]); }
293 fprintf(tf, "\n");
294 fprintf(tf, "UPD_CON_IN_PLACE: %11ld: ", UPD_CON_IN_PLACE_ctr);
295 for (i = 0; i < 9; i++) { fprintf(tf, "%11ld", UPD_CON_IN_PLACE_hst[i]); }
296 fprintf(tf, "\n");
297 fprintf(tf, "UPD_PAP_IN_NEW: %11ld: ", UPD_PAP_IN_NEW_ctr);
298 for (i = 0; i < 9; i++) { fprintf(tf, "%11ld", UPD_PAP_IN_NEW_hst[i]); }
299 fprintf(tf, "\n");
300 #endif
301
302 if (tot_gengc_updates != 0) {
303 fprintf(tf,"\nNEW GEN UPDATES: %9ld (%5.1f%%)\n",
304 tot_new_updates,
305 PC(INTAVG(tot_new_updates,tot_gengc_updates)));
306 fprintf(tf,"OLD GEN UPDATES: %9ld (%5.1f%%)\n",
307 tot_old_updates,
308 PC(INTAVG(tot_old_updates,tot_gengc_updates)));
309 }
310
311 printRegisteredCounterInfo(tf);
312
313 fprintf(tf,"\n**************************************************\n");
314
315 /* here, we print out all the raw numbers; these are really
316 more useful when we want to snag them for subsequent
317 rdb-etc processing. WDP 95/11
318 */
319
320 #define PR_CTR(ctr) \
321 do { fprintf(tf,"%11" FMT_Int " " #ctr "\n", ctr); } while(0)
322 /* COND_PR_CTR takes a boolean; if false then msg is the printname rather than ctr */
323 #define COND_PR_CTR(ctr,b,msg) \
324 if (b) { fprintf(tf,"%11" FMT_Int " " #ctr "\n", ctr); } else { fprintf(tf,"%11" FMT_Int " " msg "\n", ctr); }
325 #define PR_HST(hst,i) \
326 do { fprintf(tf,"%11ld " #hst "_" #i "\n", hst[i]); } while(0)
327
328 ALLOC_HEAP_ctr = (StgInt)ALLOC_HEAP_ctr + (StgInt)ALLOC_RTS_ctr;
329 ALLOC_HEAP_tot = (StgInt)ALLOC_HEAP_tot + (StgInt)ALLOC_RTS_tot;
330
331 PR_CTR(ALLOC_HEAP_ctr);
332 PR_CTR(ALLOC_HEAP_tot);
333
334 PR_CTR(HEAP_CHK_ctr);
335 PR_CTR(STK_CHK_ctr);
336
337 PR_CTR(ALLOC_RTS_ctr);
338 PR_CTR(ALLOC_RTS_tot);
339
340 PR_CTR(ALLOC_FUN_ctr);
341 PR_CTR(ALLOC_FUN_gds);
342
343 PR_CTR(ALLOC_PAP_ctr);
344 PR_CTR(ALLOC_PAP_adm);
345 PR_CTR(ALLOC_PAP_gds);
346
347 PR_CTR(ALLOC_UP_THK_ctr);
348 PR_CTR(ALLOC_SE_THK_ctr);
349 PR_CTR(ALLOC_THK_gds);
350
351 PR_CTR(ALLOC_CON_ctr);
352 PR_CTR(ALLOC_CON_gds);
353
354 PR_CTR(ALLOC_PRIM_ctr);
355 PR_CTR(ALLOC_PRIM_gds);
356 PR_CTR(ALLOC_PRIM_slp);
357
358 /* krc: comment out some of this stuff temporarily
359 PR_HST(ALLOC_FUN_hst,0);
360 PR_HST(ALLOC_FUN_hst,1);
361 PR_HST(ALLOC_FUN_hst,2);
362 PR_HST(ALLOC_FUN_hst,3);
363 PR_HST(ALLOC_FUN_hst,4);
364 PR_CTR(ALLOC_UP_THK_ctr);
365 PR_CTR(ALLOC_SE_THK_ctr);
366 PR_CTR(ALLOC_THK_adm);
367 PR_CTR(ALLOC_THK_gds);
368 PR_CTR(ALLOC_THK_slp);
369 PR_HST(ALLOC_THK_hst,0);
370 PR_HST(ALLOC_THK_hst,1);
371 PR_HST(ALLOC_THK_hst,2);
372 PR_HST(ALLOC_THK_hst,3);
373 PR_HST(ALLOC_THK_hst,4);
374 PR_CTR(ALLOC_CON_ctr);
375 PR_CTR(ALLOC_CON_adm);
376 PR_CTR(ALLOC_CON_gds);
377 PR_CTR(ALLOC_CON_slp);
378 PR_HST(ALLOC_CON_hst,0);
379 PR_HST(ALLOC_CON_hst,1);
380 PR_HST(ALLOC_CON_hst,2);
381 PR_HST(ALLOC_CON_hst,3);
382 PR_HST(ALLOC_CON_hst,4);
383 PR_CTR(ALLOC_TUP_ctr);
384 PR_CTR(ALLOC_TUP_adm);
385 PR_CTR(ALLOC_TUP_gds);
386 PR_CTR(ALLOC_TUP_slp);
387 PR_HST(ALLOC_TUP_hst,0);
388 PR_HST(ALLOC_TUP_hst,1);
389 PR_HST(ALLOC_TUP_hst,2);
390 PR_HST(ALLOC_TUP_hst,3);
391 PR_HST(ALLOC_TUP_hst,4);
392 PR_CTR(ALLOC_BH_ctr);
393 PR_CTR(ALLOC_BH_adm);
394 PR_CTR(ALLOC_BH_gds);
395 PR_CTR(ALLOC_BH_slp);
396 PR_HST(ALLOC_BH_hst,0);
397 PR_HST(ALLOC_BH_hst,1);
398 PR_HST(ALLOC_BH_hst,2);
399 PR_HST(ALLOC_BH_hst,3);
400 PR_HST(ALLOC_BH_hst,4);
401 PR_CTR(ALLOC_PRIM_ctr);
402 PR_CTR(ALLOC_PRIM_adm);
403 PR_CTR(ALLOC_PRIM_gds);
404 PR_CTR(ALLOC_PRIM_slp);
405 PR_HST(ALLOC_PRIM_hst,0);
406 PR_HST(ALLOC_PRIM_hst,1);
407 PR_HST(ALLOC_PRIM_hst,2);
408 PR_HST(ALLOC_PRIM_hst,3);
409 PR_HST(ALLOC_PRIM_hst,4);
410 PR_CTR(ALLOC_PAP_slp);
411 PR_HST(ALLOC_PAP_hst,0);
412 PR_HST(ALLOC_PAP_hst,1);
413 PR_HST(ALLOC_PAP_hst,2);
414 PR_HST(ALLOC_PAP_hst,3);
415 PR_HST(ALLOC_PAP_hst,4);
416
417 PR_CTR(ALLOC_TSO_ctr);
418 PR_CTR(ALLOC_TSO_adm);
419 PR_CTR(ALLOC_TSO_gds);
420 PR_CTR(ALLOC_TSO_slp);
421 PR_HST(ALLOC_TSO_hst,0);
422 PR_HST(ALLOC_TSO_hst,1);
423 PR_HST(ALLOC_TSO_hst,2);
424 PR_HST(ALLOC_TSO_hst,3);
425 PR_HST(ALLOC_TSO_hst,4);
426 */
427
428 PR_CTR(ENT_VIA_NODE_ctr);
429 PR_CTR(ENT_STATIC_CON_ctr);
430 PR_CTR(ENT_DYN_CON_ctr);
431 PR_CTR(ENT_STATIC_FUN_DIRECT_ctr);
432 PR_CTR(ENT_DYN_FUN_DIRECT_ctr);
433 PR_CTR(ENT_LNE_ctr);
434 PR_CTR(ENT_STATIC_IND_ctr);
435 PR_CTR(ENT_DYN_IND_ctr);
436
437 /* The counters ENT_PERM_IND and UPD_{NEW,OLD}_PERM_IND are not dumped
438 * at the end of execution unless update squeezing is turned off (+RTS
439 * -Z =RtsFlags.GcFlags.squeezeUpdFrames), as they will be wrong
440 * otherwise. Why? Because for each update frame squeezed out, we
441 * count an UPD_NEW_PERM_IND *at GC time* (i.e., too early). And
442 * further, when we enter the closure that has been updated, we count
443 * the ENT_PERM_IND, but we then enter the PERM_IND that was built for
444 * the next update frame below, and so on down the chain until we
445 * finally reach the value. Thus we count many new ENT_PERM_INDs too
446 * early.
447 *
448 * This of course refers to the -ticky version that uses PERM_INDs to
449 * determine the number of closures entered 0/1/>1. KSW 1999-04. */
450 COND_PR_CTR(ENT_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsFalse,"E!NT_PERM_IND_ctr requires +RTS -Z");
451
452 PR_CTR(ENT_AP_ctr);
453 PR_CTR(ENT_PAP_ctr);
454 PR_CTR(ENT_AP_STACK_ctr);
455 PR_CTR(ENT_BH_ctr);
456 PR_CTR(ENT_STATIC_THK_SINGLE_ctr);
457 PR_CTR(ENT_STATIC_THK_MANY_ctr);
458 PR_CTR(ENT_DYN_THK_SINGLE_ctr);
459 PR_CTR(ENT_DYN_THK_MANY_ctr);
460 PR_CTR(UPD_CAF_BH_UPDATABLE_ctr);
461 PR_CTR(UPD_CAF_BH_SINGLE_ENTRY_ctr);
462
463 PR_CTR(SLOW_CALL_fast_v16_ctr);
464 PR_CTR(SLOW_CALL_fast_v_ctr);
465 PR_CTR(SLOW_CALL_fast_f_ctr);
466 PR_CTR(SLOW_CALL_fast_d_ctr);
467 PR_CTR(SLOW_CALL_fast_l_ctr);
468 PR_CTR(SLOW_CALL_fast_n_ctr);
469 PR_CTR(SLOW_CALL_fast_p_ctr);
470 PR_CTR(SLOW_CALL_fast_pv_ctr);
471 PR_CTR(SLOW_CALL_fast_pp_ctr);
472 PR_CTR(SLOW_CALL_fast_ppv_ctr);
473 PR_CTR(SLOW_CALL_fast_ppp_ctr);
474 PR_CTR(SLOW_CALL_fast_pppv_ctr);
475 PR_CTR(SLOW_CALL_fast_pppp_ctr);
476 PR_CTR(SLOW_CALL_fast_ppppp_ctr);
477 PR_CTR(SLOW_CALL_fast_pppppp_ctr);
478 PR_CTR(VERY_SLOW_CALL_ctr);
479
480 PR_CTR(UNKNOWN_CALL_ctr);
481 PR_CTR(KNOWN_CALL_ctr);
482 PR_CTR(KNOWN_CALL_TOO_FEW_ARGS_ctr);
483 PR_CTR(KNOWN_CALL_EXTRA_ARGS_ctr);
484 PR_CTR(MULTI_CHUNK_SLOW_CALL_ctr);
485 PR_CTR(MULTI_CHUNK_SLOW_CALL_CHUNKS_ctr);
486 PR_CTR(SLOW_CALL_ctr);
487 PR_CTR(SLOW_CALL_FUN_TOO_FEW_ctr);
488 PR_CTR(SLOW_CALL_FUN_CORRECT_ctr);
489 PR_CTR(SLOW_CALL_FUN_TOO_MANY_ctr);
490 PR_CTR(SLOW_CALL_PAP_TOO_FEW_ctr);
491 PR_CTR(SLOW_CALL_PAP_CORRECT_ctr);
492 PR_CTR(SLOW_CALL_PAP_TOO_MANY_ctr);
493 PR_CTR(SLOW_CALL_UNEVALD_ctr);
494
495 /* krc: put off till later... */
496 #if FALSE
497 PR_HST(SLOW_CALL_hst,0);
498 PR_HST(SLOW_CALL_hst,1);
499 PR_HST(SLOW_CALL_hst,2);
500 PR_HST(SLOW_CALL_hst,3);
501 PR_HST(SLOW_CALL_hst,4);
502 PR_HST(SLOW_CALL_hst,5);
503 PR_HST(SLOW_CALL_hst,6);
504 PR_HST(SLOW_CALL_hst,7);
505 #endif
506
507 PR_CTR(RET_NEW_ctr);
508 PR_CTR(RET_OLD_ctr);
509 PR_CTR(RET_UNBOXED_TUP_ctr);
510
511 /* krc: put off till later... */
512 #if FALSE
513 PR_HST(RET_NEW_hst,0);
514 PR_HST(RET_NEW_hst,1);
515 PR_HST(RET_NEW_hst,2);
516 PR_HST(RET_NEW_hst,3);
517 PR_HST(RET_NEW_hst,4);
518 PR_HST(RET_NEW_hst,5);
519 PR_HST(RET_NEW_hst,6);
520 PR_HST(RET_NEW_hst,7);
521 PR_HST(RET_NEW_hst,8);
522 PR_HST(RET_OLD_hst,0);
523 PR_HST(RET_OLD_hst,1);
524 PR_HST(RET_OLD_hst,2);
525 PR_HST(RET_OLD_hst,3);
526 PR_HST(RET_OLD_hst,4);
527 PR_HST(RET_OLD_hst,5);
528 PR_HST(RET_OLD_hst,6);
529 PR_HST(RET_OLD_hst,7);
530 PR_HST(RET_OLD_hst,8);
531 PR_HST(RET_UNBOXED_TUP_hst,0);
532 PR_HST(RET_UNBOXED_TUP_hst,1);
533 PR_HST(RET_UNBOXED_TUP_hst,2);
534 PR_HST(RET_UNBOXED_TUP_hst,3);
535 PR_HST(RET_UNBOXED_TUP_hst,4);
536 PR_HST(RET_UNBOXED_TUP_hst,5);
537 PR_HST(RET_UNBOXED_TUP_hst,6);
538 PR_HST(RET_UNBOXED_TUP_hst,7);
539 PR_HST(RET_UNBOXED_TUP_hst,8);
540 #endif /* FALSE */
541
542 PR_CTR(UPDF_OMITTED_ctr);
543 PR_CTR(UPDF_PUSHED_ctr);
544 PR_CTR(CATCHF_PUSHED_ctr);
545
546 PR_CTR(UPDF_RCC_PUSHED_ctr);
547 PR_CTR(UPDF_RCC_OMITTED_ctr);
548
549 PR_CTR(UPD_SQUEEZED_ctr);
550 PR_CTR(UPD_CON_IN_NEW_ctr);
551 PR_CTR(UPD_CON_IN_PLACE_ctr);
552 PR_CTR(UPD_PAP_IN_NEW_ctr);
553 PR_CTR(UPD_PAP_IN_PLACE_ctr);
554
555
556 /* krc: put off till later...*/
557 #if FALSE
558 PR_HST(UPD_CON_IN_NEW_hst,0);
559 PR_HST(UPD_CON_IN_NEW_hst,1);
560 PR_HST(UPD_CON_IN_NEW_hst,2);
561 PR_HST(UPD_CON_IN_NEW_hst,3);
562 PR_HST(UPD_CON_IN_NEW_hst,4);
563 PR_HST(UPD_CON_IN_NEW_hst,5);
564 PR_HST(UPD_CON_IN_NEW_hst,6);
565 PR_HST(UPD_CON_IN_NEW_hst,7);
566 PR_HST(UPD_CON_IN_NEW_hst,8);
567 PR_HST(UPD_PAP_IN_NEW_hst,0);
568 PR_HST(UPD_PAP_IN_NEW_hst,1);
569 PR_HST(UPD_PAP_IN_NEW_hst,2);
570 PR_HST(UPD_PAP_IN_NEW_hst,3);
571 PR_HST(UPD_PAP_IN_NEW_hst,4);
572 PR_HST(UPD_PAP_IN_NEW_hst,5);
573 PR_HST(UPD_PAP_IN_NEW_hst,6);
574 PR_HST(UPD_PAP_IN_NEW_hst,7);
575 PR_HST(UPD_PAP_IN_NEW_hst,8);
576 #endif /* FALSE */
577
578 PR_CTR(UPD_NEW_IND_ctr);
579 /* see comment on ENT_PERM_IND_ctr */
580 COND_PR_CTR(UPD_NEW_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsFalse,"U!PD_NEW_PERM_IND_ctr requires +RTS -Z");
581 PR_CTR(UPD_OLD_IND_ctr);
582 /* see comment on ENT_PERM_IND_ctr */
583 COND_PR_CTR(UPD_OLD_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsFalse,"U!PD_OLD_PERM_IND_ctr requires +RTS -Z");
584
585 PR_CTR(GC_SEL_ABANDONED_ctr);
586 PR_CTR(GC_SEL_MINOR_ctr);
587 PR_CTR(GC_SEL_MAJOR_ctr);
588 PR_CTR(GC_FAILED_PROMOTION_ctr);
589 }
590
591 /* To print out all the registered-counter info: */
592
593 static void
594 printRegisteredCounterInfo (FILE *tf)
595 {
596 StgEntCounter *p;
597
598 if ( ticky_entry_ctrs != NULL ) {
599 fprintf(tf,"\nThe following table is explained by http://ghc.haskell.org/trac/ghc/wiki/Debugging/TickyTicky\nAll allocation numbers are in bytes.\n");
600 fprintf(tf,"\n**************************************************\n\n");
601 }
602 fprintf(tf, "%11s%11s%11s %-23s %s\n",
603 "Entries", "Alloc", "Alloc'd", "Non-void Arguments", "STG Name");
604 fprintf(tf, "--------------------------------------------------------------------------------\n");
605 /* Function name at the end so it doesn't mess up the tabulation */
606
607 for (p = ticky_entry_ctrs; p != NULL; p = p->link) {
608 fprintf(tf, "%11" FMT_Int "%11" FMT_Int "%11" FMT_Int " %3lu %-20.20s %s",
609 p->entry_count,
610 p->allocs,
611 p->allocd,
612 (unsigned long)p->arity,
613 p->arg_kinds,
614 p->str);
615
616 fprintf(tf, "\n");
617
618 }
619 }
620 #endif /* TICKY_TICKY */
621