Log profiler: removed the hsmode option, use heapshot=MODE instead.
authorPaolo Molaro <lupus@oddwiz.org>
Fri, 12 Nov 2010 19:54:10 +0000 (20:54 +0100)
committerPaolo Molaro <lupus@oddwiz.org>
Fri, 12 Nov 2010 20:38:05 +0000 (21:38 +0100)
man/mprof-report.1
mono/profiler/log-profiler.txt
mono/profiler/proflog.c

index 142a916da10ddf0d3643e4372cffc876365e932a..5c3be5d7a5681f23633907292f669aadca0bc78e 100644 (file)
@@ -101,16 +101,16 @@ See the \f[I]maxframes\f[] option to control this behaviour.
 \f[I]calls\f[] enables method enter/leave events if they were
 disabled by another option like \f[I]heapshot\f[].
 .IP \[bu] 2
-\f[I]heapshot\f[]: collect heap shot data at each major collection.
+\f[I]heapshot[=MODE]\f[]: collect heap shot data at each major
+collection.
 The frequency of the heap shots can be changed with the
-\f[I]hsmode\f[] option below.
+\f[I]MODE\f[] 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.
-.IP \[bu] 2
-\f[I]hsmode=MODE\f[]: modify the default heap shot frequency
-according to MODE.
-hsmode can be used multiple times with different modes: in that
+The optional parameter \f[I]MODE\f[] 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:
 .RS 2
@@ -140,18 +140,28 @@ call chain depth is bigger than NUM.
 format.
 .IP \[bu] 2
 \f[I]output=OUTSPEC\f[]: instead of writing the profiling data to
-the output.mlpd file, do according to \f[I]OUTSPEC\f[]:
+the output.mlpd file, substitute \f[I]%p\f[] in \f[I]OUTSPEC\f[]
+with the current process id and \f[I]%t\f[] with the current date
+and time, then do according to \f[I]OUTSPEC\f[]:
 .RS 2
 .IP \[bu] 2
 if \f[I]OUTSPEC\f[] begins with a \f[I]|\f[] character, execute the
 rest as a program and feed the data to its standard input
 .IP \[bu] 2
-otherwise write the data the the named file
+if \f[I]OUTSPEC\f[] begins with a \f[I]-\f[] character, use the
+rest of OUTSPEC as the filename, but force overwrite any existing
+file by that name
+.IP \[bu] 2
+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.
 .RE
 .IP \[bu] 2
 \f[I]report\f[]: the profiling data is sent to mprof-report, which
 will print a summary report.
 This is equivalent to the option: \f[B]output=mprof-report\ -\f[].
+If the \f[I]output\f[] option is specified as well, the report will
+be written to the output file instead of the console.
 .SS Analyzing the profile data
 .PP
 Currently there is a command line program (\f[I]mprof-report\f[])
@@ -347,8 +357,8 @@ 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 \f[I]hsmode\f[] option can be used to reduce the frequency of
-the heap shots.
+The \f[I]MODE\f[] parameter of the \f[I]heapshot\f[] option can be
+used to reduce the frequency of the heap shots.
 .SS Reduce the timestamp overhead
 .PP
 On many operating systems or architectures what actually slows down
@@ -401,15 +411,14 @@ option.
 .PP
 Heap shot data can also be huge: by default it is collected at each
 major collection.
-To reduce the frequency, you can use the \f[I]hsmode\f[] profiler
-option to collect for example every 5 collections (including major
-and minor):
+To reduce the frequency, you can specify a heapshot mode: for
+example to collect every 5 collections (including major and minor):
 .PP
-\f[B]hsmode=5gc\f[]
+\f[B]heapshot=5gc\f[]
 .PP
 or when at least 5 seconds passed since the last heap shot:
 .PP
-\f[B]hsmode=5000ms\f[]
+\f[B]heapshot=5000ms\f[]
 .SS Compressing the data
 .PP
 To reduce the amout of disk space used by the data, the data can be
index 5ae4496d8078c88ad35ee44249752beb437cd49a..a04ecf4918af5e32da211e4a7a438c57487d56f8 100644 (file)
@@ -80,13 +80,12 @@ 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
@@ -286,8 +285,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
 
@@ -331,14 +331,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
 
index 46059226c4ef02010658ff65a2a0b0ac08848d85..b92088fc0200ebad057bbf292feb3c49fad132b7 100644 (file)
@@ -1103,8 +1103,8 @@ usage (int do_exit)
        printf ("\thelp             show this usage info\n");
        printf ("\t[no]alloc        enable/disable recording allocation info\n");
        printf ("\t[no]calls        enable/disable recording enter/leave method events\n");
-       printf ("\theapshot         record heap shot info (by default at each major collection)\n");
-       printf ("\thsmode=MODE      heapshot mode: every XXms milliseconds or every YYgc collections\n");
+       printf ("\theapshot[=MODE]  record heap shot info (by default at each major collection)\n");
+       printf ("\t                 heapshot MODE: every XXms milliseconds or every YYgc collections\n");
        printf ("\ttime=fast        use a faster (but more inaccurate) timer\n");
        printf ("\tmaxframes=NUM    collect up to NUM stack frames\n");
        printf ("\tcalldepth=NUM    ignore method events for call chain depth bigger than NUM\n");
@@ -1139,6 +1139,10 @@ match_option (const char* p, const char *opt, char **rval)
                                *rval = val;
                                return opt + l;
                        }
+                       if (p [len] == 0 || p [len] == ',') {
+                               *rval = NULL;
+                               return p + len + (p [len] == ',');
+                       }
                        usage (1);
                } else {
                        if (p [len] == 0)
@@ -1150,6 +1154,25 @@ match_option (const char* p, const char *opt, char **rval)
        return p;
 }
 
+static void
+set_hsmode (char* val, int allow_empty)
+{
+       char *end;
+       unsigned int count;
+       if (allow_empty && !val)
+               return;
+       count = strtoul (val, &end, 10);
+       if (val == end)
+               usage (1);
+       if (strcmp (end, "ms") == 0)
+               hs_mode_ms = count;
+       else if (strcmp (end, "gc") == 0)
+               hs_mode_gc = count;
+       else
+               usage (1);
+       free (val);
+}
+
 /* 
  * declaration to silence the compiler: this is the entry point that
  * mono will load from the shared library and call.
@@ -1219,25 +1242,17 @@ mono_profiler_startup (const char *desc)
                        do_report = 1;
                        continue;
                }
-               if ((opt = match_option (p, "heapshot", NULL)) != p) {
+               if ((opt = match_option (p, "heapshot", &val)) != p) {
                        events &= ~MONO_PROFILE_ALLOCATIONS;
                        events &= ~MONO_PROFILE_ENTER_LEAVE;
                        nocalls = 1;
                        do_heap_shot = 1;
+                       set_hsmode (val, 1);
                        continue;
                }
                if ((opt = match_option (p, "hsmode", &val)) != p) {
-                       char *end;
-                       unsigned int count = strtoul (val, &end, 10);
-                       if (val == end)
-                               usage (1);
-                       if (strcmp (end, "ms") == 0)
-                               hs_mode_ms = count;
-                       else if (strcmp (end, "gc") == 0)
-                               hs_mode_gc = count;
-                       else
-                               usage (1);
-                       free (val);
+                       fprintf (stderr, "The hsmode profiler option is obsolete, use heapshot=MODE.\n");
+                       set_hsmode (val, 0);
                        continue;
                }
                if ((opt = match_option (p, "zip", NULL)) != p) {