1 <chapter id="profiling">
2 <title>Profiling</Title>
3 <indexterm><primary>profiling</primary>
5 <indexterm><primary>cost-centre profiling</primary></indexterm>
7 <Para> Glasgow Haskell comes with a time and space profiling
8 system. Its purpose is to help you improve your understanding of
9 your program's execution behaviour, so you can improve it.</Para>
11 <Para> Any comments, suggestions and/or improvements you have are
12 welcome. Recommended “profiling tricks” would be
13 especially cool! </Para>
15 <para>Profiling a program is a three-step process:</para>
19 <para> Re-compile your program for profiling with the
20 <literal>-prof</literal> option, and probably one of the
21 <literal>-auto</literal> or <literal>-auto-all</literal>
22 options. These options are described in more detail in <xref
23 linkend="prof-compiler-options"> </para>
24 <indexterm><primary><literal>-prof</literal></primary>
26 <indexterm><primary><literal>-auto</literal></primary>
28 <indexterm><primary><literal>-auto-all</literal></primary>
33 <para> Run your program with one of the profiling options
34 <literal>-p</literal> or <literal>-h</literal>. This generates
35 a file of profiling information.</para>
36 <indexterm><primary><literal>-p</literal></primary><secondary>RTS
37 option</secondary></indexterm>
38 <indexterm><primary><literal>-h</literal></primary><secondary>RTS
39 option</secondary></indexterm>
43 <para> Examine the generated profiling information, using one of
44 GHC's profiling tools. The tool to use will depend on the kind
45 of profiling information generated.</para>
51 <title>Cost centres and cost-centre stacks</title>
53 <para>GHC's profiling system assigns <firstterm>costs</firstterm>
54 to <firstterm>cost centres</firstterm>. A cost is simply the time
55 or space required to evaluate an expression. Cost centres are
56 program annotations around expressions; all costs incurred by the
57 annotated expression are assigned to the enclosing cost centre.
58 Furthermore, GHC will remember the stack of enclosing cost centres
59 for any given expression at run-time and generate a call-graph of
60 cost attributions.</para>
62 <para>Let's take a look at an example:</para>
65 main = print (nfib 25)
66 nfib n = if n < 2 then 1 else nfib (n-1) + nfib (n-2)
69 <para>Compile and run this program as follows:</para>
72 $ ghc -prof -auto-all -o Main Main.hs
78 <para>When a GHC-compiled program is run with the
79 <option>-p</option> RTS option, it generates a file called
80 <filename><prog>.prof</filename>. In this case, the file
81 will contain something like this:</para>
84 Fri May 12 14:06 2000 Time and Allocation Profiling Report (Final)
88 total time = 0.14 secs (7 ticks @ 20 ms)
89 total alloc = 8,741,204 bytes (excludes profiling overheads)
91 COST CENTRE MODULE %time %alloc
97 COST CENTRE MODULE scc %time %alloc %time %alloc
99 MAIN MAIN 0 0.0 0.0 100.0 100.0
100 main Main 0 0.0 0.0 0.0 0.0
101 CAF PrelHandle 3 0.0 0.0 0.0 0.0
102 CAF PrelAddr 1 0.0 0.0 0.0 0.0
103 CAF Main 6 0.0 0.0 100.0 100.0
104 main Main 1 0.0 0.0 100.0 100.0
105 nfib Main 242785 100.0 100.0 100.0 100.0
109 <para>The first part of the file gives the program name and
110 options, and the total time and total memory allocation measured
111 during the run of the program (note that the total memory
112 allocation figure isn't the same as the amount of
113 <emphasis>live</emphasis> memory needed by the program at any one
114 time; the latter can be determined using heap profiling, which we
115 will describe shortly).</para>
117 <para>The second part of the file is a break-down by cost centre
118 of the most costly functions in the program. In this case, there
119 was only one significant function in the program, namely
120 <function>nfib</function>, and it was responsible for 100%
121 of both the time and allocation costs of the program.</para>
123 <para>The third and final section of the file gives a profile
124 break-down by cost-centre stack. This is roughly a call-graph
125 profile of the program. In the example above, it is clear that
126 the costly call to <function>nfib</function> came from
127 <function>main</function>.</para>
129 <para>The time and allocation incurred by a given part of the
130 program is displayed in two ways: “individual”, which
131 are the costs incurred by the code covered by this cost centre
132 stack alone, and “inherited”, which includes the costs
133 incurred by all the children of this node.</para>
135 <para>The usefulness of cost-centre stacks is better demonstrated
136 by modifying the example slightly:</para>
139 main = print (f 25 + g 25)
141 g n = nfib (n `div` 2)
142 nfib n = if n < 2 then 1 else nfib (n-1) + nfib (n-2)
145 <para>Compile and run this program as before, and take a look at
146 the new profiling results:</para>
149 COST CENTRE MODULE scc %time %alloc %time %alloc
151 MAIN MAIN 0 0.0 0.0 100.0 100.0
152 main Main 0 0.0 0.0 0.0 0.0
153 CAF PrelHandle 3 0.0 0.0 0.0 0.0
154 CAF PrelAddr 1 0.0 0.0 0.0 0.0
155 CAF Main 9 0.0 0.0 100.0 100.0
156 main Main 1 0.0 0.0 100.0 100.0
157 g Main 1 0.0 0.0 0.0 0.2
158 nfib Main 465 0.0 0.2 0.0 0.2
159 f Main 1 0.0 0.0 100.0 99.8
160 nfib Main 242785 100.0 99.8 100.0 99.8
163 <para>Now although we had two calls to <function>nfib</function>
164 in the program, it is immediately clear that it was the call from
165 <function>f</function> which took all the time.</para>
167 <para>The actual meaning of the various columns in the output is:</para>
173 <para>The number of times this particular point in the call
174 graph was entered.</para>
179 <term>individual %time</term>
181 <para>The percentage of the total run time of the program
182 spent at this point in the call graph.</para>
187 <term>individual %alloc</term>
189 <para>The percentage of the total memory allocations
190 (excluding profiling overheads) of the program made by this
196 <term>inherited %time</term>
198 <para>The percentage of the total run time of the program
199 spent below this point in the call graph.</para>
204 <term>inherited %alloc</term>
206 <para>The percentage of the total memory allocations
207 (excluding profiling overheads) of the program made by this
208 call and all of its sub-calls.</para>
213 <para>In addition you can use the <Option>-P</Option> RTS option
214 <indexterm><primary><option>-P</option></primary></indexterm> to
215 get the following additional information:</para>
219 <term><literal>ticks</literal></term>
221 <Para>The raw number of time “ticks” which were
222 attributed to this cost-centre; from this, we get the
223 <literal>%time</literal> figure mentioned
229 <term><literal>bytes</literal></term>
231 <Para>Number of bytes allocated in the heap while in this
232 cost-centre; again, this is the raw number from which we get
233 the <literal>%alloc</literal> figure mentioned
239 <para>What about recursive functions, and mutually recursive
240 groups of functions? Where are the costs attributed? Well,
241 although GHC does keep information about which groups of functions
242 called each other recursively, this information isn't displayed in
243 the basic time and allocation profile, instead the call-graph is
244 flattened into a tree. The XML profiling tool (described in <xref
245 linkend="prof-xml-tool">) will be able to display real loops in
246 the call-graph.</para>
248 <sect2><title>Inserting cost centres by hand</title>
250 <para>Cost centres are just program annotations. When you say
251 <option>-auto-all</option> to the compiler, it automatically
252 inserts a cost centre annotation around every top-level function
253 in your program, but you are entirely free to add the cost
254 centre annotations yourself.</para>
256 <para>The syntax of a cost centre annotation is</para>
259 _scc_ "name" <expression>
262 <para>where <literal>"name"</literal> is an aribrary string,
263 that will become the name of your cost centre as it appears
264 in the profiling output, and
265 <literal><expression></literal> is any Haskell
266 expression. An <literal>_scc_</literal> annotation extends as
267 far to the right as possible when parsing.</para>
271 <sect2 id="prof-rules">
272 <title>Rules for attributing costs</title>
274 <para>The cost of evaluating any expression in your program is
275 attributed to a cost-centre stack using the following rules:</para>
279 <para>If the expression is part of the
280 <firstterm>one-off</firstterm> costs of evaluating the
281 enclosing top-level definition, then costs are attributed to
282 the stack of lexically enclosing <literal>_scc_</literal>
283 annotations on top of the special <literal>CAF</literal>
288 <para>Otherwise, costs are attributed to the stack of
289 lexically-enclosing <literal>_scc_</literal> annotations,
290 appended to the cost-centre stack in effect at the
291 <firstterm>call site</firstterm> of the current top-level
292 definition<footnote> <para>The call-site is just the place
293 in the source code which mentions the particular function or
294 variable.</para></footnote>. Notice that this is a recursive
299 <para>What do we mean by one-off costs? Well, Haskell is a lazy
300 language, and certain expressions are only ever evaluated once.
301 For example, if we write:</para>
307 <para>then <varname>x</varname> will only be evaluated once (if
308 at all), and subsequent demands for <varname>x</varname> will
309 immediately get to see the cached result. The definition
310 <varname>x</varname> is called a CAF (Constant Applicative
311 Form), because it has no arguments.</para>
313 <para>For the purposes of profiling, we say that the expression
314 <literal>nfib 25</literal> belongs to the one-off costs of
315 evaluating <varname>x</varname>.</para>
317 <para>Since one-off costs aren't strictly speaking part of the
318 call-graph of the program, they are attributed to a special
319 top-level cost centre, <literal>CAF</literal>. There may be one
320 <literal>CAF</literal> cost centre for each module (the
321 default), or one for each top-level definition with any one-off
322 costs (this behaviour can be selected by giving GHC the
323 <option>-caf-all</option> flag).</para>
325 <indexterm><primary><literal>-caf-all</literal></primary>
328 <para>If you think you have a weird profile, or the call-graph
329 doesn't look like you expect it to, feel free to send it (and
330 your program) to us at
331 <email>glasgow-haskell-bugs@haskell.org</email>.</para>
336 <sect1 id="prof-heap">
337 <title>Profiling memory usage</title>
339 <para>In addition to profiling the time and allocation behaviour
340 of your program, you can also generate a graph of its memory usage
341 over time. This is useful for detecting the causes of
342 <firstterm>space leaks</firstterm>, when your program holds on to
343 more memory at run-time that it needs to. Space leaks lead to
344 longer run-times due to heavy garbage collector ativity, and may
345 even cause the program to run out of memory altogether.</para>
347 <para>To generate a heap profile from your program, compile it as
348 before, but this time run it with the <option>-h</option> runtime
349 option. This generates a file
350 <filename><prog>.hp</filename> file, which you then process
351 with <command>hp2ps</command> to produce a Postscript file
352 <filename><prog>.ps</filename>. The Postscript file can be
353 viewed with something like <command>ghostview</command>, or
354 printed out on a Postscript-compatible printer.</para>
356 <para>For the RTS options that control the kind of heap profile
357 generated, see <xref linkend="prof-rts-options">. Details on the
358 usage of the <command>hp2ps</command> program are given in <xref
359 linkend="hp2ps"></para>
363 <sect1 id="prof-xml-tool">
364 <title>Graphical time/allocation profile</title>
366 <para>You can view the time and allocation profiling graph of your
367 program graphically, using <command>ghcprof</command>. This is a
368 new tool with GHC 4.07, and will eventually be the de-facto
369 standard way of viewing GHC profiles.</para>
371 <para>To run <command>ghcprof</command>, you need
372 <productname>daVinci</productname> installed, which can be
374 url="http://www.tzi.de/~davinci/"><citetitle>The Graph
375 Visualisation Tool daVinci</citetitle></ulink>. Install one of
377 distributions<footnote><para><productname>daVinci</productname> is
378 sadly not open-source :-(.</para></footnote>, and set your
379 <envar>DAVINCIHOME</envar> environment variable to point to the
380 installation directory.</para>
382 <para><command>ghcprof</command> uses an XML-based profiling log
383 format, and you therefore need to run your program with a
384 different option: <option>-px</option>. The file generated is
385 still called <filename><prog>.prof</filename>. To see the
386 profile, run <command>ghcprof</command> like this:</para>
388 <indexterm><primary><option>-px</option></primary></indexterm>
391 $ ghcprof <prog>.prof
394 <para>which should pop up a window showing the call-graph of your
395 program in glorious detail. More information on using
396 <command>ghcprof</command> can be found at <ulink
397 url="http://www.dcs.warwick.ac.uk/people/academic/Stephen.Jarvis/profiler/index.html"><citetitle>The
398 Cost-Centre Stack Profiling Tool for
399 GHC</citetitle></ulink>.</para>
403 <sect1 id="prof-compiler-options">
404 <title>Compiler options for profiling</title>
406 <indexterm><primary>profiling</primary><secondary>options</secondary></indexterm>
407 <indexterm><primary>options</primary><secondary>for profiling</secondary></indexterm>
409 <Para> To make use of the cost centre profiling system
410 <Emphasis>all</Emphasis> modules must be compiled and linked with
411 the <Option>-prof</Option> option. Any
412 <Function>_scc_</Function> constructs you've put in
413 your source will spring to life.</Para>
415 <indexterm><primary><literal>-prof</literal></primary></indexterm>
417 <Para> Without a <Option>-prof</Option> option, your
418 <Function>_scc_</Function>s are ignored; so you can
419 compiled <Function>_scc_</Function>-laden code
420 without changing it.</Para>
422 <Para>There are a few other profiling-related compilation options.
423 Use them <Emphasis>in addition to</Emphasis>
424 <Option>-prof</Option>. These do not have to be used consistently
425 for all modules in a program.</Para>
430 <term><Option>-auto</Option>:</Term>
431 <indexterm><primary><literal>-auto</literal></primary></indexterm>
432 <indexterm><primary>cost centres</primary><secondary>automatically inserting</secondary></indexterm>
434 <Para> GHC will automatically add
435 <Function>_scc_</Function> constructs for all
436 top-level, exported functions.</Para>
441 <term><Option>-auto-all</Option>:</Term>
442 <indexterm><primary><literal>-auto-all</literal></primary></indexterm>
444 <Para> <Emphasis>All</Emphasis> top-level functions,
445 exported or not, will be automatically
446 <Function>_scc_</Function>'d.</Para>
451 <term><Option>-caf-all</Option>:</Term>
452 <indexterm><primary><literal>-caf-all</literal></primary></indexterm>
454 <Para> The costs of all CAFs in a module are usually
455 attributed to one “big” CAF cost-centre. With
456 this option, all CAFs get their own cost-centre. An
457 “if all else fails” option…</Para>
462 <term><Option>-ignore-scc</Option>:</Term>
463 <indexterm><primary><literal>-ignore-scc</literal></primary></indexterm>
465 <Para>Ignore any <Function>_scc_</Function>
466 constructs, so a module which already has
467 <Function>_scc_</Function>s can be compiled
468 for profiling with the annotations ignored.</Para>
476 <sect1 id="prof-rts-options">
477 <title>Runtime options for profiling</Title>
479 <indexterm><primary>profiling RTS options</primary></indexterm>
480 <indexterm><primary>RTS options, for profiling</primary></indexterm>
482 <Para>It isn't enough to compile your program for profiling with
483 <Option>-prof</Option>!</Para>
485 <Para>When you <Emphasis>run</Emphasis> your profiled program, you
486 must tell the runtime system (RTS) what you want to profile (e.g.,
487 time and/or space), and how you wish the collected data to be
488 reported. You also may wish to set the sampling interval used in
489 time profiling.</Para>
491 <Para>Executive summary: <command>./a.out +RTS -pT</command>
492 produces a time profile in <Filename>a.out.prof</Filename>;
493 <command>./a.out +RTS -hC</command> produces space-profiling info
494 which can be mangled by <command>hp2ps</command> and viewed with
495 <command>ghostview</command> (or equivalent).</Para>
497 <Para>Profiling runtime flags are passed to your program between
498 the usual <Option>+RTS</Option> and <Option>-RTS</Option>
504 <term><Option>-p</Option> or <Option>-P</Option>:</Term>
505 <indexterm><primary><option>-p</option></primary></indexterm>
506 <indexterm><primary><option>-P</option></primary></indexterm>
507 <indexterm><primary>time profile</primary></indexterm>
509 <Para>The <Option>-p</Option> option produces a standard
510 <Emphasis>time profile</Emphasis> report. It is written
512 <Filename><program>.prof</Filename>.</Para>
514 <Para>The <Option>-P</Option> option produces a more
515 detailed report containing the actual time and allocation
516 data as well. (Not used much.)</Para>
521 <term><option>-px</option>:</term>
522 <indexterm><primary><option>-px</option></primary></indexterm>
524 <para>The <option>-px</option> option generates profiling
525 information in the XML format understood by our new
526 profiling tool, see <xref linkend="prof-xml-tool">.</para>
531 <term><Option>-i<secs></Option>:</Term>
532 <indexterm><primary><option>-i</option></primary></indexterm>
534 <Para> Set the profiling (sampling) interval to
535 <literal><secs></literal> seconds (the default is
536 1 second). Fractions are allowed: for example
537 <Option>-i0.2</Option> will get 5 samples per second. This
538 only affects heap profiling; time profiles are always
539 sampled on a 1/50 second frequency.</Para>
544 <term><Option>-h<break-down></Option>:</Term>
545 <indexterm><primary><option>-h<break-down></option></primary></indexterm>
546 <indexterm><primary>heap profile</primary></indexterm>
548 <Para>Produce a detailed <Emphasis>heap profile</Emphasis>
549 of the heap occupied by live closures. The profile is
550 written to the file <Filename><program>.hp</Filename>
551 from which a PostScript graph can be produced using
552 <command>hp2ps</command> (see <XRef
553 LinkEnd="hp2ps">).</Para>
555 <Para>The heap space profile may be broken down by different
561 <term><Option>-hC</Option>:</Term>
563 <Para>cost centre which produced the closure (the
569 <term><Option>-hM</Option>:</Term>
571 <Para>cost centre module which produced the
577 <term><Option>-hD</Option>:</Term>
579 <Para>closure description—a string describing
585 <term><Option>-hY</Option>:</Term>
587 <Para>closure type—a string describing the
588 closure's type.</Para>
597 <term><option>-hx</option>:</term>
598 <indexterm><primary><option>-hx</option></primary></indexterm>
600 <para>The <option>-hx</option> option generates heap
601 profiling information in the XML format understood by our
602 new profiling tool (NOTE: heap profiling with the new tool
603 is not yet working! Use <command>hp2ps</command>-style heap
604 profiling for the time being).</para>
613 <title><command>hp2ps</command>--heap profile to PostScript</title>
615 <indexterm><primary><command>hp2ps</command></primary></indexterm>
616 <indexterm><primary>heap profiles</primary></indexterm>
617 <indexterm><primary>postscript, from heap profiles</primary></indexterm>
618 <indexterm><primary><option>-h<break-down></option></primary></indexterm>
623 hp2ps [flags] [<file>[.hp]]
627 <command>hp2ps</command><indexterm><primary>hp2ps
628 program</primary></indexterm> converts a heap profile as produced
629 by the <Option>-h<break-down></Option> runtime option into a
630 PostScript graph of the heap profile. By convention, the file to
631 be processed by <command>hp2ps</command> has a
632 <filename>.hp</filename> extension. The PostScript output is
633 written to <filename><file>@.ps</filename>. If
634 <filename><file></filename> is omitted entirely, then the
635 program behaves as a filter.</para>
637 <para><command>hp2ps</command> is distributed in
638 <filename>ghc/utils/hp2ps</filename> in a GHC source
639 distribution. It was originally developed by Dave Wakeling as part
640 of the HBC/LML heap profiler.</para>
642 <para>The flags are:</para>
647 <term><Option>-d</Option></Term>
649 <para>In order to make graphs more readable,
650 <command>hp2ps</command> sorts the shaded bands for each
651 identifier. The default sort ordering is for the bands with
652 the largest area to be stacked on top of the smaller ones.
653 The <Option>-d</Option> option causes rougher bands (those
654 representing series of values with the largest standard
655 deviations) to be stacked on top of smoother ones.</para>
660 <term><Option>-b</Option></Term>
662 <para>Normally, <command>hp2ps</command> puts the title of
663 the graph in a small box at the top of the page. However, if
664 the JOB string is too long to fit in a small box (more than
665 35 characters), then <command>hp2ps</command> will choose to
666 use a big box instead. The <Option>-b</Option> option
667 forces <command>hp2ps</command> to use a big box.</para>
672 <term><Option>-e<float>[in|mm|pt]</Option></Term>
674 <para>Generate encapsulated PostScript suitable for
675 inclusion in LaTeX documents. Usually, the PostScript graph
676 is drawn in landscape mode in an area 9 inches wide by 6
677 inches high, and <command>hp2ps</command> arranges for this
678 area to be approximately centred on a sheet of a4 paper.
679 This format is convenient of studying the graph in detail,
680 but it is unsuitable for inclusion in LaTeX documents. The
681 <Option>-e</Option> option causes the graph to be drawn in
682 portrait mode, with float specifying the width in inches,
683 millimetres or points (the default). The resulting
684 PostScript file conforms to the Encapsulated PostScript
685 (EPS) convention, and it can be included in a LaTeX document
686 using Rokicki's dvi-to-PostScript converter
687 <command>dvips</command>.</para>
692 <term><Option>-g</Option></Term>
694 <para>Create output suitable for the <command>gs</command>
695 PostScript previewer (or similar). In this case the graph is
696 printed in portrait mode without scaling. The output is
697 unsuitable for a laser printer.</para>
702 <term><Option>-l</Option></Term>
704 <para>Normally a profile is limited to 20 bands with
705 additional identifiers being grouped into an
706 <literal>OTHER</literal> band. The <Option>-l</Option> flag
707 removes this 20 band and limit, producing as many bands as
708 necessary. No key is produced as it won't fit!. It is useful
709 for creation time profiles with many bands.</para>
714 <term><Option>-m<int></Option></Term>
716 <para>Normally a profile is limited to 20 bands with
717 additional identifiers being grouped into an
718 <literal>OTHER</literal> band. The <Option>-m</Option> flag
719 specifies an alternative band limit (the maximum is
722 <para><Option>-m0</Option> requests the band limit to be
723 removed. As many bands as necessary are produced. However no
724 key is produced as it won't fit! It is useful for displaying
725 creation time profiles with many bands.</para>
730 <term><Option>-p</Option></Term>
732 <para>Use previous parameters. By default, the PostScript
733 graph is automatically scaled both horizontally and
734 vertically so that it fills the page. However, when
735 preparing a series of graphs for use in a presentation, it
736 is often useful to draw a new graph using the same scale,
737 shading and ordering as a previous one. The
738 <Option>-p</Option> flag causes the graph to be drawn using
739 the parameters determined by a previous run of
740 <command>hp2ps</command> on <filename>file</filename>. These
741 are extracted from <filename>file@.aux</filename>.</para>
746 <term><Option>-s</Option></Term>
748 <para>Use a small box for the title.</para>
753 <term><Option>-t<float></Option></Term>
755 <para>Normally trace elements which sum to a total of less
756 than 1% of the profile are removed from the
757 profile. The <option>-t</option> option allows this
758 percentage to be modified (maximum 5%).</para>
760 <para><Option>-t0</Option> requests no trace elements to be
761 removed from the profile, ensuring that all the data will be
767 <term><Option>-c</Option></Term>
769 <para>Generate colour output.</para>
774 <term><Option>-y</Option></Term>
776 <para>Ignore marks.</para>
781 <term><Option>-?</Option></Term>
783 <para>Print out usage information.</para>
789 <sect1 id="ticky-ticky">
790 <title>Using “ticky-ticky” profiling (for implementors)</Title>
791 <indexterm><primary>ticky-ticky profiling</primary></indexterm>
793 <para>(ToDo: document properly.)</para>
795 <para>It is possible to compile Glasgow Haskell programs so that
796 they will count lots and lots of interesting things, e.g., number
797 of updates, number of data constructors entered, etc., etc. We
798 call this “ticky-ticky”
799 profiling,<indexterm><primary>ticky-ticky
800 profiling</primary></indexterm> <indexterm><primary>profiling,
801 ticky-ticky</primary></indexterm> because that's the sound a Sun4
802 makes when it is running up all those counters
803 (<Emphasis>slowly</Emphasis>).</para>
805 <para>Ticky-ticky profiling is mainly intended for implementors;
806 it is quite separate from the main “cost-centre”
807 profiling system, intended for all users everywhere.</para>
809 <para>To be able to use ticky-ticky profiling, you will need to
810 have built appropriate libraries and things when you made the
811 system. See “Customising what libraries to build,” in
812 the installation guide.</para>
814 <para>To get your compiled program to spit out the ticky-ticky
815 numbers, use a <Option>-r</Option> RTS
816 option<indexterm><primary>-r RTS option</primary></indexterm>.
817 See <XRef LinkEnd="runtime-control">.</para>
819 <para>Compiling your program with the <Option>-ticky</Option>
820 switch yields an executable that performs these counts. Here is a
821 sample ticky-ticky statistics file, generated by the invocation
822 <command>foo +RTS -rfoo.ticky</command>.</para>
828 ALLOCATIONS: 3964631 (11330900 words total: 3999476 admin, 6098829 goods, 1232595 slop)
829 total words: 2 3 4 5 6+
830 69647 ( 1.8%) function values 50.0 50.0 0.0 0.0 0.0
831 2382937 ( 60.1%) thunks 0.0 83.9 16.1 0.0 0.0
832 1477218 ( 37.3%) data values 66.8 33.2 0.0 0.0 0.0
834 2 ( 0.0%) black holes 0.0 100.0 0.0 0.0 0.0
835 0 ( 0.0%) prim things
836 34825 ( 0.9%) partial applications 0.0 0.0 0.0 100.0 0.0
837 2 ( 0.0%) thread state objects 0.0 0.0 0.0 0.0 100.0
839 Total storage-manager allocations: 3647137 (11882004 words)
840 [551104 words lost to speculative heap-checks]
844 ENTERS: 9400092 of which 2005772 (21.3%) direct to the entry code
845 [the rest indirected via Node's info ptr]
846 1860318 ( 19.8%) thunks
847 3733184 ( 39.7%) data values
848 3149544 ( 33.5%) function values
849 [of which 1999880 (63.5%) bypassed arg-satisfaction chk]
850 348140 ( 3.7%) partial applications
851 308906 ( 3.3%) normal indirections
852 0 ( 0.0%) permanent indirections
855 2137257 ( 36.4%) from entering a new constructor
856 [the rest from entering an existing constructor]
857 2349219 ( 40.0%) vectored [the rest unvectored]
859 RET_NEW: 2137257: 32.5% 46.2% 21.3% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
860 RET_OLD: 3733184: 2.8% 67.9% 29.3% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
861 RET_UNBOXED_TUP: 2: 0.0% 0.0%100.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
863 RET_VEC_RETURN : 2349219: 0.0% 0.0%100.0% 0.0% 0.0% 0.0% 0.0% 0.0% 0.0%
865 UPDATE FRAMES: 2241725 (0 omitted from thunks)
869 0 ( 0.0%) data values
870 34827 ( 1.6%) partial applications
871 [2 in place, 34825 allocated new space]
872 2206898 ( 98.4%) updates to existing heap objects (46 by squeezing)
873 UPD_CON_IN_NEW: 0: 0 0 0 0 0 0 0 0 0
874 UPD_PAP_IN_NEW: 34825: 0 0 0 34825 0 0 0 0 0
876 NEW GEN UPDATES: 2274700 ( 99.9%)
878 OLD GEN UPDATES: 1852 ( 0.1%)
880 Total bytes copied during GC: 190096
882 **************************************************
883 3647137 ALLOC_HEAP_ctr
884 11882004 ALLOC_HEAP_tot
889 34831 ALLOC_FUN_hst_0
890 34816 ALLOC_FUN_hst_1
894 2382937 ALLOC_UP_THK_ctr
897 0 E!NT_PERM_IND_ctr requires +RTS -Z
898 [... lots more info omitted ...]
899 0 GC_SEL_ABANDONED_ctr
902 0 GC_FAILED_PROMOTION_ctr
903 47524 GC_WORDS_COPIED_ctr
906 <para>The formatting of the information above the row of asterisks
907 is subject to change, but hopefully provides a useful
908 human-readable summary. Below the asterisks <Emphasis>all
909 counters</Emphasis> maintained by the ticky-ticky system are
910 dumped, in a format intended to be machine-readable: zero or more
911 spaces, an integer, a space, the counter name, and a newline.</para>
913 <para>In fact, not <Emphasis>all</Emphasis> counters are
914 necessarily dumped; compile- or run-time flags can render certain
915 counters invalid. In this case, either the counter will simply
916 not appear, or it will appear with a modified counter name,
917 possibly along with an explanation for the omission (notice
918 <literal>ENT_PERM_IND_ctr</literal> appears
919 with an inserted <literal>!</literal> above). Software analysing
920 this output should always check that it has the counters it
921 expects. Also, beware: some of the counters can have
922 <Emphasis>large</Emphasis> values!</para>
929 ;;; Local Variables: ***
931 ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***