Add -pa and -V to the documentation of time profiling options.
[ghc-hetmet.git] / docs / users_guide / profiling.xml
index 9a1f289..5fb53d0 100644 (file)
@@ -33,7 +33,9 @@
     <listitem>
       <para> Run your program with one of the profiling options, eg.
       <literal>+RTS -p -RTS</literal>.  This generates a file of
-      profiling information.</para>
+      profiling information.  Note that multi-processor execution
+      (e.g. <literal>+RTS -N2</literal>) is not supported while
+      profiling.</para>
       <indexterm><primary><option>-p</option></primary><secondary>RTS
       option</secondary></indexterm>
     </listitem>
@@ -264,6 +266,27 @@ MAIN                     MAIN             0    0.0   0.0    100.0 100.0
       far to the right as possible when parsing. (SCC stands for "Set
       Cost Centre").</para>
 
+      <para>Here is an example of a program with a couple of SCCs:</para>
+
+<programlisting>
+main :: IO ()
+main = do let xs = {-# SCC "X" #-} [1..1000000]
+          let ys = {-# SCC "Y" #-} [1..2000000]
+          print $ last xs
+          print $ last $ init xs
+          print $ last ys
+          print $ last $ init ys
+</programlisting>
+
+      <para>which gives this heap profile when run:</para>
+
+      <!-- contentwidth/contentheight don't appear to have any effect
+           other than making the PS file generation work, rather than
+           falling over.  The result seems to be broken PS on the page
+           with the image. -->
+      <imagedata fileref="prof_scc" contentwidth="645px"
+      contentdepth="428px"/>
+
     </sect2>
 
     <sect2 id="prof-rules">
@@ -435,9 +458,10 @@ x = nfib 25
     <variablelist>
       <varlistentry>
        <term>
-          <option>-p</option> or <option>-P</option>:
+          <option>-p</option> or <option>-P</option> or <option>-pa</option>:
           <indexterm><primary><option>-p</option></primary></indexterm>
           <indexterm><primary><option>-P</option></primary></indexterm>
+          <indexterm><primary><option>-pa</option></primary></indexterm>
           <indexterm><primary>time profile</primary></indexterm>
         </term>
        <listitem>
@@ -449,9 +473,24 @@ x = nfib 25
          <para>The <option>-P</option> option produces a more
           detailed report containing the actual time and allocation
           data as well.  (Not used much.)</para>
+
+          <para>The <option>-pa</option> option produces the most detailed
+          report containing all cost centres in addition to the actual time
+          and allocation data.</para>
        </listitem>
       </varlistentry>
 
+     <varlistentry>
+       <term><option>-V<replaceable>secs</replaceable></option>
+       <indexterm><primary><option>-V</option></primary><secondary>RTS
+       option</secondary></indexterm></term>
+       <listitem>
+         <para>Sets the interval that the RTS clock ticks at, which is
+         also the sampling interval of the time and allocation profile.
+         The default is 0.02&nbsp;second.</para>
+       </listitem>
+     </varlistentry>
+
       <varlistentry>
        <term>
           <option>-xc</option>
@@ -507,6 +546,11 @@ x = nfib 25
       </listitem>
     </orderedlist>
 
+    <para>You might also want to take a look
+      at <ulink url="http://www.haskell.org/haskellwiki/Hp2any">hp2any</ulink>,
+      a more advanced suite of tools (not distributed with GHC) for
+      displaying heap profiles.</para>
+
     <sect2 id="rts-options-heap-prof">
       <title>RTS options for heap profiling</title>
 
@@ -712,7 +756,8 @@ x = nfib 25
             0.1&nbsp;second).  Fractions are allowed: for example
             <option>-i0.2</option> will get 5 samples per second.
             This only affects heap profiling; time profiles are always
-            sampled on a 1/50 second frequency.</para>
+            sampled with the frequency of the RTS clock. See
+            <xref linkend="prof-time-options"/> for changing that.</para>
          </listitem>
        </varlistentry>
 
@@ -1256,7 +1301,7 @@ to re-read its input file:
     <indexterm><primary>hpc</primary></indexterm>
 
     <para>
-      Code coverage tools allow a programer to determine what parts of
+      Code coverage tools allow a programmer to determine what parts of
       their code have been actually executed, and which parts have
       never actually been invoked.  GHC has an option for generating
       instrumented code that records code coverage as part of the
@@ -1573,13 +1618,13 @@ Options:
 
     <para>(ToDo: document properly.)</para>
 
-    <para>It is possible to compile Glasgow Haskell programs so that
+    <para>It is possible to compile Haskell programs so that
     they will count lots and lots of interesting things, e.g., number
     of updates, number of data constructors entered, etc., etc.  We
     call this &ldquo;ticky-ticky&rdquo;
     profiling,<indexterm><primary>ticky-ticky
     profiling</primary></indexterm> <indexterm><primary>profiling,
-    ticky-ticky</primary></indexterm> because that's the sound a Sun4
+    ticky-ticky</primary></indexterm> because that's the sound a CPU
     makes when it is running up all those counters
     (<emphasis>slowly</emphasis>).</para>
 
@@ -1587,25 +1632,52 @@ Options:
     it is quite separate from the main &ldquo;cost-centre&rdquo;
     profiling system, intended for all users everywhere.</para>
 
-    <para>To be able to use ticky-ticky profiling, you will need to
-    have built the ticky RTS. (This should be described in 
-    the building guide, but amounts to building the RTS with way
-    "t" enabled.)</para>
+    <para>
+      You don't need to build GHC, the libraries, or the RTS a special
+      way in order to use ticky-ticky profiling.  You can decide on a
+      module-by-module basis which parts of a program have the
+      counters compiled in, using the
+      compile-time <option>-ticky</option> option.  Those modules that
+      were not compiled with <option>-ticky</option> won't contribute
+      to the ticky-ticky profiling results, and that will normally
+      include all the pre-compiled packages that your program links
+      with.
+    </para>
 
-    <para>To get your compiled program to spit out the ticky-ticky
-    numbers, use a <option>-r</option> RTS
-    option<indexterm><primary>-r RTS option</primary></indexterm>.
-    See <xref linkend="runtime-control"/>.</para>
+    <para>
+      To get your compiled program to spit out the ticky-ticky
+      numbers:
 
-    <para>Compiling your program with the <option>-ticky</option>
-    switch yields an executable that performs these counts.  Here is a
-    sample ticky-ticky statistics file, generated by the invocation
-    <command>foo +RTS -rfoo.ticky</command>.</para>
+      <itemizedlist>
+        <listitem>
+          <para>
+            Link the program with <option>-debug</option>
+            (<option>-ticky</option> is a synonym
+            for <option>-debug</option> at link-time).  This links in
+            the debug version of the RTS, which includes the code for
+            aggregating and reporting the results of ticky-ticky
+            profilng.
+          </para>
+        </listitem>
+        <listitem>
+          <para>
+            Run the program with the <option>-r</option> RTS
+            option<indexterm><primary>-r RTS option</primary></indexterm>.
+            See <xref linkend="runtime-control"/>.
+          </para>
+        </listitem>
+      </itemizedlist>
+    </para>
 
+    <para>
+      Here is a sample ticky-ticky statistics file, generated by
+      the invocation
+      <command>foo +RTS -rfoo.ticky</command>.
+      </para>
+    
 <screen>
  foo +RTS -rfoo.ticky
 
-
 ALLOCATIONS: 3964631 (11330900 words total: 3999476 admin, 6098829 goods, 1232595 slop)
                                 total words:        2     3     4     5    6+
   69647 (  1.8%) function values                 50.0  50.0   0.0   0.0   0.0