Fix warnings reported by clang.
[mono.git] / mono / profiler / log-profiler.txt
index 0d6349b6f248af16781e38b0e2d417a073457374..10140c6b3bbcab47fc007d8b870f4b9471650880 100644 (file)
@@ -22,6 +22,10 @@ The events collected include (among others):
 In addition, the profiler can periodically collect info about all the objects
 present in the heap at the end of a garbage collection (this is called heap shot
 and currently implemented only for the sgen garbage collector).
+Another available profiler mode is the *sampling* or *statistical* mode:
+periodically the program is sampled and the information about what the program was
+busy with is saved. This allows to get information about the program behaviour
+without degrading its performance too much (usually less than 10%).
 
 ## Basic profiler usage
 
@@ -50,13 +54,18 @@ the needed info can be gathered with:
 `mono --profile=log:nocalls program.exe`
 
 You will still be able to inspect information about the sequence of calls that lead
-to each allocation because at each object allocation a stack trace is collected as well.
+to each allocation because at each object allocation a stack trace is collected if
+full enter/leave information is not available.
 
 To periodically collect heap shots (and exclude method and allocation events) use the
 following options (making sure you run with the sgen garbage collector):
 
 `mono --gc=sgen --profile=log:heapshot program.exe`
 
+To perform a sampling profiler run, use the *sample* option:
+
+`mono --profile=log:sample program.exe`
+
 ## Profiler option documentation
 
 By default the *log* profiler will gather all the events provided by the Mono runtime
@@ -80,20 +89,31 @@ and exception throws) a stack trace is collected by default. See the *maxframes*
 control this behaviour. *calls* enables method enter/leave events if they were disabled
 by another option like *heapshot*.
 
-* *heapshot*: collect heap shot data at each major collection. The frequency of the
-heap shots can be changed with the *hsmode* option below. When this option is used
+* *heapshot[=MODE]*: collect heap shot data at each major collection. The frequency of the
+heap shots can be changed with the *MODE* parameter. When this option is used
 allocation events and method enter/leave events are not recorded by default: if they
 are needed, they need to be enabled explicitly.
-
-* *hsmode=MODE*: modify the default heap shot frequency according to MODE.
-hsmode can be used multiple times with different modes: in that case a heap shot is
+The optional parameter *MODE* can modify the default heap shot frequency.
+heapshot can be used multiple times with different modes: in that case a heap shot is
 taken if either of the conditions are met.
 MODE can be one of:
        * *NUM*ms: perform a heap shot if at least *NUM* milliseconds passed since
        the last one.
-       * *NUM*gc: perform a heap shot every *NUM* garbage collections (either
-       minor or major).
-
+       * *NUM*gc: perform a heap shot every *NUM* major garbage collections
+       * *ondemand*: perform a heap shot when such a command is sent to the
+       control port
+
+* *sample[=TYPE[/FREQ]]*: collect statistical samples of the program behaviour. The
+default is to collect a 1000 times per second the instruction pointer. This is
+equivalent to the value "cycles/1000" for *TYPE*. On some systems, like with recent
+Linux kernels, it is possible to cause the sampling to happen for other events
+provided by the performance counters of the cpu. In this case, *TYPE* can be one of:
+       * *cycles*: processor cycles
+       * *instr*: executed instructions
+       * *cacherefs*: cache references
+       * *cachemiss*: cache misses
+       * *branches*: executed branches
+       * *branchmiss*: mispredicted branches
 
 * *time=TIMER*: use the TIMER timestamp mode. TIMER can have the following values:
        * *fast*: a usually faster but possibly more inaccurate timer
@@ -107,13 +127,27 @@ bigger than NUM.
 * *zip*: automatically compress the output data in gzip format.
 
 * *output=OUTSPEC*: instead of writing the profiling data to the output.mlpd file,
-do according to *OUTSPEC*:
+substitute *%p* in *OUTSPEC* with the current process id and *%t* with the current
+date and time, then do according to *OUTSPEC*:
        * if *OUTSPEC* begins with a *|* character, execute the rest as a program
        and feed the data to its standard input
-       * otherwise write the data the the named file
+       * if *OUTSPEC* begins with a *-* character, use the rest of OUTSPEC as
+       the filename, but force overwrite any existing file by that name
+       * if *OUTSPEC* begins with a *#* character, use the rest of OUTSPEC as a
+       file descriptor and feed the data to it.
+       * otherwise write the data the the named file: note that is a file by that
+       name already exists, a warning is issued and profiling is disabled.
 
 * *report*: the profiling data is sent to mprof-report, which will print a summary
-report. This is equivalent to the option: `output=mprof-report -`.
+report. This is equivalent to the option: `output=mprof-report -`. If the *output*
+option is specified as well, the report will be written to the output file instead of
+the console.
+
+* *port=PORT*: specify the tcp/ip port to use for the listening command server.
+Currently not available for windows.
+This server is started for example when heapshot=ondemand is used: it will read
+commands line by line. The following commands are available:
+       * *heapshot*: perform a heapshot as soon as possible
 
 ## Analyzing the profile data
 
@@ -192,6 +226,9 @@ option:
 
 where the report names R1, R2 etc. can be:
 
+* *header*: information about program startup and profiler version
+* *jit*: JIT compiler information
+* *sample*: statistical sampling information
 * *gc*: garbage collection information
 * *alloc*: object allocation information
 * *call*: method profiling information
@@ -251,6 +288,11 @@ of FINDSPEC. For example, the following:
 
 will find all the byte arrays that are at least 10000 bytes in size.
 
+Note that with a moving garbage collector the object address can change, so
+you may need to track the changed address manually. It can also happen that
+multiple objects are allocated at the same address, so the output from this
+option can become large.
+
 ### Saving a profiler report
 
 By default mprof-report will print the summary data to the console.
@@ -264,6 +306,13 @@ If the profiler needs to collect lots of data, the execution of the program will
 slow down significantly, usually 10 to 20 times slower. There are several
 ways to reduce the impact of the profiler on the program execution.
 
+### Use the statistical sampling mode
+
+Statistical sampling allows executing a program under the profiler with minimal
+performance overhead (usually less than 10%). This mode allows checking where
+the program is spending most of it's execution time without significantly
+perturbing its behaviour.
+
 ### Collect less data
 
 Collecting method enter/leave events can be very expensive, especially in programs
@@ -280,8 +329,9 @@ by setting a low value with the *maxframes* option or by eliminating them
 completely, by setting it to 0.
 
 The other major source of data is the heapshot profiler option: especially
-if the managed heap is big, since every object needs to be inspected. The *hsmode*
-option can be used to reduce the frequency of the heap shots.
+if the managed heap is big, since every object needs to be inspected. The *MODE*
+parameter of the *heapshot* option can be used to reduce the frequency of the heap
+shots.
 
 ### Reduce the timestamp overhead
 
@@ -291,11 +341,6 @@ The *time=fast* profiler option can be usually used to speed up this operation,
 but, depending on the system, time accounting may have some level of approximation
 (though statistically the data should be still fairly valuable).
 
-### Use a statistical profiler instead
-
-See the mono manpage for the use of a statistical (sampling) profiler.
-The *log* profiler will be enhanced to provide sampling info in the future.
-
 ## Dealing with the size of the data files
 
 When collecting a lot of information about a profiled program, huge data
@@ -325,14 +370,14 @@ data, use the *maxframes=0* profiler option.
 Allocation events can be eliminated with the *noalloc* option.
 
 Heap shot data can also be huge: by default it is collected at each major collection.
-To reduce the frequency, you can use the *hsmode* profiler option to collect for example
+To reduce the frequency, you can specify a heapshot mode: for example to collect
 every 5 collections (including major and minor):
 
-`hsmode=5gc`
+`heapshot=5gc`
 
 or when at least 5 seconds passed since the last heap shot:
 
-`hsmode=5000ms`
+`heapshot=5000ms`
 
 ### Compressing the data