3 mono\-profilers \- Mono's bundled profiler modules
5 \fBmono\ \-\-profile=log\fR[:\fIoption\fR,...] \fIprogram.exe\fR [\fIargs\fR]...
7 \fBmono\ \-\-profile=coverage\fR[:\fIoption\fR,...] \fIprogram.exe\fR [\fIargs\fR]...
9 \fBmono\ \-\-profile=aot\fR[:\fIoption\fR,...] \fIprogram.exe\fR [\fIargs\fR]...
11 Mono ships with a few profiler modules that enable most typical
12 profiling scenarios. This page describes each of them in the sections
15 The log profiler is Mono's general-purpose performance profiler. It
16 can collect a wide variety of data that can be analyzed by tools such
17 as \fBmprof\-report\fR(1) or the Xamarin Profiler.
19 By default, the log profiler writes its output to \fIoutput.mlpd\fR.
20 Refer to the \fImono/profiler/log.h\fR file in the Mono source tree
21 for documentation on the log profiler's file format.
23 A default invocation of the log profiler gathers only basic data:
24 Metadata load and unload events, thread start and stop events,
25 performance counter samples, exception throws, etc. Most users will
26 want to enable some of the heavier features such as GC allocation
27 recording, statistical sampling, heap snapshotting (heapshots), or
28 method entry and exit instrumentation. See the \fBOptions\fR
31 Note that, in most realistic scenarios, the log profiler will record
32 a vast amount of data. This can lead to very large log files. (The
33 \fBzip\fR and \fBreport\fR options can help deal with this.)
35 The log profiler supports the following options:
38 Print usage instructions.
40 \fBoutput\fR=[\fI+\fR|\fI#\fR|\fI|\fR]\fIfile\fR
41 Write log data to \fIfile\fR. The optional modifiers are:
46 The program PID is appended to the file name. For example,
47 \fBoutput=+out.mlpd\fR outputs to \fIout.mlpd.1234\fR if the PID is
51 \fIfile\fR is parsed as a file descriptor number, which is opened
52 with \fBfdopen\fR(3). This is mainly useful in embedding scenarios.
55 \fIfile\fR is treated as a program name. It will be started with
56 \fBpopen\fR(3) and the log data will be piped to its standard input.
60 Generate a report directly instead of writing the log data to a file.
61 If this option is used together with the \fBoutput\fR option, the
62 report will be written to the specified file instead of the log data.
65 Compress the output file with \fBgzip\fR(1).
68 Use \fIport\fR to listen for command server connections. See the
69 \fBCommand server\fR sub-section.
72 Disables pre Mono 5.6 compatibility. In particular, this disables
73 exception events and performance counter sampling by default. It also
74 makes it so that GC move events won't be enabled by default when
75 heapshots are enabled. To use this option, it must be the first
76 option given to the log profiler.
78 This option will be the default in a future version of the log
82 Enable or disable gathering data for \fIevent\fR, which can be one
87 Exception throw and clause (\fBcatch\fR, \fBfinally\fR, etc)
88 evaluation events. Enabled by default unless \fBnodefaults\fR is
92 Monitor lock contention, acquisition, and release events.
95 GC start, progress, stop, and resize events.
104 GC root report events. Generated on every collection if enabled,
105 unless \fBnodefaults\fR is used, in which case, they're only
106 generated on heapshots.
109 GC handle creation and deletion events.
112 Object finalization events.
115 Performance counter sample events. Enabled by default unless
116 \fBnodefaults\fR is used.
119 JIT code buffer events.
122 Alias for \fBgc\fR, \fBgcalloc\fR, and \fBgcmove\fR.
125 Alias for \fBexception\fR, \fBmonitor\fR, \fBgc\fR, \fBgcmove\fR,
126 \fBgcroot\fR, \fBgchandle\fR, \fBfinalization\fR, and \fBcounter\fR.
129 \fBsample\fR[\fB\-real\fR][=\fIfreq\fR]
130 Enable statistical sampling. The default is to sample at a frequency
131 of 100 Hz, but \fIfreq\fR can be used to override this.
133 By default, sampling uses process time (i.e., the more work a process
134 does, the more samples are collected). The \fB-real\fR variant uses
135 wall clock time instead. Wall clock time is better for programs that
138 \fBmaxsamples\fR=\fInum\fR
139 Limit the number of reusable sample events to \fInum\fR allocations.
140 A value of zero means no limit. By default, the value of this setting
141 is based on the number of CPU cores. Some tinkering with this setting
142 may be necessary for programs with an unusually high amount of
146 Enable method entry and exit instrumentation. This is an alternative
147 to statistical sampling when you need more precise information. Note
148 that this mode is extremely heavy and can slow most programs to a
151 \fBcallspec\fR=\fIspec\fR
152 Limit method entry and exit instrumentation to methods matching the
153 specified call spec. This uses the same syntax as the \fB--trace\fR
154 option for \fBmono\fR(1), so refer to that page for more information.
156 \fBcalldepth\fR=\fInum\fR
157 Limit method entry and exit event collection to a call depth of
160 \fBmaxframes\fR=\fInum\fR
161 Limit backtraces in various events (including statistical samples) to
164 \fBheapshot\fR[=\fImode\fR]
165 Enable heap snapshots. \fImode\fR, if given, can be one of:
169 Only perform a heapshot when receiving a command via the command
170 server or when triggered through the managed library.
173 Perform a heapshot on every \fInum\fR collections of the major
177 Perform a heapshot on a major generation collection if \fInum\fR
178 milliseconds have passed since the last heapshot.
181 If \fImode\fR is not given, a heapshot will be performed on every
182 collection of the major generation.
184 \fBheapshot-on-shutdown\fR
185 In addition to any other heapshot settings, also perform a heapshot
189 Print detailed debugging information. Most users should not use this
192 The log profiler features a simple command server that currently is
193 only used to trigger manual heapshots (typcally when using the
194 on-demand mode, but also usable with the other modes). A random port
195 will be used to listen for connections unless the \fBport\fR option
196 is used. To trigger a heapshot, open a TCP connection to the command
197 server and send the C string \fB"heapshot\\n"\fR.
199 The command server supports multiple simultaneous connections.
201 The log profiler comes with a managed library called
202 \fBMono.Profiler.Log\fR. This library allows easily reading log files
203 in managed code (e.g., C#) as well as interacting with the profiler
206 With the ability to easily read log files, users can write all sorts
207 of interesting analyses that might not be provided by the standard
208 tools (e.g., \fBmprof\-report\fR(1)).
210 The \fBLogProfiler\fR class allows users to reconfigure profiler
211 settings at run-time. For example, certain event types can be toggled
212 on or off, the mode and frequency of heapshots and sampling can be
213 changed, etc. Heapshots can also be triggered manually.
215 To use this library, simply pass \fB\-r:Mono.Profiler.Log\fR when
218 Collect GC allocation and sampling data for a program, then generate
223 mono \-\-profile=log:alloc,sample program.exe
224 mprof\-report output.mlpd
228 Perform a heapshot on every 5th collection and generate a report
233 mono \-\-profile=log:heapshot=5gc,report program.exe
237 .SH COVERAGE PROFILER
238 The code coverage profiler collects information about how often code
239 paths are executed. This is done by instrumenting JIT-compiled code
240 at all sequence points. On program exit, the coverage profiler
241 collects all execution count information and outputs it to an XML
242 file. The main use case for the coverage profiler is unit testing: By
243 running unit test suites with the coverage profiler, it is possible
244 to determine whether the unit tests actually cover all the code that
247 By default, the coverage profiler writes its output to
248 \fIcoverage.xml\fR. Refer to the \fImono/profiler/coverage.c\fR file
249 in the Mono source tree for documentation on the schema.
251 Please note that the coverage profiler currently does not support
252 instrumenting AOT-compiled code. When collecting coverage data, one
253 may wish to run Mono with the \fB-O=-aot\fR option to disable loading
256 The coverage profiler supports the following options:
259 Print usage instructions.
261 \fBoutput\fR=[\fI+\fR|\fI#\fR|\fI|\fR]\fIfile\fR
262 Write coverage data to \fIfile\fR. The optional modifiers are:
267 The program PID is appended to the file name. For example,
268 \fBoutput=+cov.xml\fR outputs to \fIcov.xml.1234\fR if the PID is
272 \fIfile\fR is parsed as a file descriptor number, which is opened
273 with \fBfdopen\fR(3). This is mainly useful in embedding scenarios.
276 \fIfile\fR is treated as a program name. It will be started with
277 \fBpopen\fR(3) and the coverage data will be piped to its standard
281 \fBcovfilter-file\fR=\fIfile\fR
282 Supply a coverage filter file. This option can be given multiple
283 times. See the \fBFilter files\fR sub-section.
285 Filter files can be used to pick and choose which types should be
286 considered for coverage instrumentation. A filter file consists of a
287 series of lines of the form:
291 \fB+\fR|\fB\-\fR\fB[\fR\fIimage_name\fR\fB]\fR\fItype_name_prefix\fR
295 Here, \fIimage_name\fR is something like \fBmscorlib\fR.
296 \fItype_name_prefix\fR can be something like \fBSystem.Int32\fR for
297 a specific type or \fBSystem.App\fR to pick all types starting with
298 \fBApp\fR in the \fBSystem\fR namespace.
300 Lines starting with \fB+\fR indicate that a type should be
301 instrumented for coverage, whereas lines starting with \fB\-\fR
302 indicate the opposite. Lines starting with \fB+\fR always override
303 lines starting with \fB\-\fR regardless of the order they appear in.
305 Lines not starting with either character are ignored. This can be
306 used to write comments. For example, this is a valid file:
310 # Ignore coverage in network-related code, except HTTP client code.
311 -[MyProgram]MyProgram.Net
312 +[MyProgram]MyProgram.Net.Http.HttpClient
316 Coverage data for a program can be collected like this:
320 mono \-O=\-aot \-\-profile=coverage:output=cov.xml program.exe
324 \fIcov.xml\fR will now contain the coverage data.
326 The AOT profiler will record which generic instantiations a program
327 makes use of and save the information to a specified file. This data
328 can then be used by the AOT compiler to compile those generic
329 instantiations ahead of time to reduce program startup time.
331 By default, the AOT profiler writes its output to
332 \fIoutput.aotprofile\fR. Refer to the \fImono/profiler/aot.h\fR file
333 in the Mono source tree for documentation on the AOT profiler's file
336 The AOT profiler supports the following options:
338 \fBduration\fR=\fInum\fR
339 Profile only NUM seconds of runtime and then write the data.
342 Print usage instructions.
344 \fBoutput\fR=[\fI+\fR|\fI#\fR|\fI|\fR]\fIfile\fR
345 Write output data to \fIfile\fR. The optional modifiers are:
350 The program PID is appended to the file name. For example,
351 \fBoutput=+out.aotprofile\fR outputs to \fIout.aotprofile.1234\fR if
352 the PID is \fB1234\fR.
355 \fIfile\fR is parsed as a file descriptor number, which is opened
356 with \fBfdopen\fR(3). This is mainly useful in embedding scenarios.
359 \fIfile\fR is treated as a program name. It will be started with
360 \fBpopen\fR(3) and the log data will be piped to its standard input.
364 Print detailed debugging information. Most users should not use this
367 A profile can be collected and used like this:
371 mono \-\-profile=aot:output=program.aotprofile program.exe
372 mono \-\-aot=profile=program.aotprofile program.exe
378 \fBmono\fR(1), \fBmprof\-report\fR(1)