1 .\" Copyright (c) 2003-2008 Joseph Koshy
2 .\" Copyright (c) 2007 The FreeBSD Foundation
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" This software is provided by Joseph Koshy ``as is'' and
15 .\" any express or implied warranties, including, but not limited to, the
16 .\" implied warranties of merchantability and fitness for a particular purpose
17 .\" are disclaimed. in no event shall Joseph Koshy be liable
18 .\" for any direct, indirect, incidental, special, exemplary, or consequential
19 .\" damages (including, but not limited to, procurement of substitute goods
20 .\" or services; loss of use, data, or profits; or business interruption)
21 .\" however caused and on any theory of liability, whether in contract, strict
22 .\" liability, or tort (including negligence or otherwise) arising in any way
23 .\" out of the use of this software, even if advised of the possibility of
33 .Nd "performance measurement with performance monitoring hardware"
44 .Op Fl M Ar mapfilename
46 .Op Fl O Ar logfilename
47 .Op Fl P Ar event-spec
48 .Op Fl R Ar logfilename
49 .Op Fl S Ar event-spec
64 .Op Fl o Ar outputfile
65 .Op Fl p Ar event-spec
68 .Op Fl s Ar event-spec
69 .Op Fl t Ar process-spec
70 .Op Fl u Ar event-spec
73 .Op Fl z Ar graphdepth
74 .Op Ar command Op Ar args
78 utility measures system performance using the facilities provided by
83 utility can measure both hardware events seen by the system as a
84 whole, and those seen when a specified set of processes are executing
86 If a specific set of processes is being targeted (for example,
89 option is specified, or if a command line is specified using
91 then measurement occurs till
93 exits, or till all target processes specified by the
95 options exit, or till the
97 utility is interrupted by the user.
98 If a specific set of processes is not targeted for measurement, then
100 will perform system-wide measurements till interrupted by the
103 A given invocation of
105 can mix allocations of system-mode and process-mode PMCs, of both
106 counting and sampling flavors.
107 The values of all counting PMCs are printed in human readable form
108 at regular intervals by
112 human-readable textual output is not stable, and could change
114 The output of sampling PMCs may be configured to go to a log file for
115 subsequent offline analysis, or, at the expense of greater
116 overhead, may be configured to be printed in text form on the fly.
118 Hardware events to measure are specified to
120 using event specifier strings
122 The syntax of these event specifiers is machine dependent and is
126 A process-mode PMC may be configured to be inheritable by the target
127 process' current and future children.
129 The following options are available:
130 .Bl -tag -width indent
132 Skip symbol lookup and display address instead.
134 Toggle between showing cumulative or incremental counts for
135 subsequent counting mode PMCs specified on the command line.
136 The default is to show incremental counts.
138 Create files with per-program samples in the directory named
141 The default is to create these files in the current directory.
143 Toggle showing per-process counts at the time a tracked process
144 exits for subsequent process-mode PMCs specified on the command line.
145 This option is useful for mapping the performance characteristics of a
146 complex pipeline of processes when used in conjunction with the
149 The default is to not to enable per-process tracking.
151 Print calltree (Kcachegrind) information to file
157 this information is sent to the output file specified by the
161 Print callchain information to file
167 this information is sent to the output file specified by the
171 Show the offset of the instruction pointer into the symbol.
173 List all event names.
174 .It Fl M Ar mapfilename
175 Write the mapping between executable objects encountered in the event
176 log and the abbreviated pathnames used for
180 If this option is not specified, mapping information is not written.
185 in which case this mapping information is sent to the output
186 file configured by the
190 Toggle capturing callchain information for subsequent sampling PMCs.
191 The default is for sampling PMCs to capture callchain information.
192 .It Fl O Ar logfilename
193 Send logging output to file
198 .Ar hostname Ns : Ns Ar port ,
201 does not start with a
207 will open a network socket to host
214 option is not specified and one of the logging options is requested,
217 will print a textual form of the logged events to the configured
219 .It Fl P Ar event-spec
220 Allocate a process mode sampling PMC measuring hardware events
223 .It Fl R Ar logfilename
224 Perform offline analysis using sampling data in file
226 .It Fl S Ar event-spec
227 Allocate a system mode sampling PMC measuring hardware events
233 mode for sampling PMCs. The following hotkeys
236 .Bl -tag -compact -width "Ctrl+a" -offset 4n
238 Toggle symbol resolution
242 Switch to accumulative mode
251 threshold as a dot (calltree only)
253 Toggle showing offsets into symbols
266 Toggle capturing user-space call traces while in kernel mode.
267 The default is for sampling PMCs to capture user-space callchain information
268 while in user-space mode, and kernel callchain information while in kernel mode.
270 Toggle logging the incremental counts seen by the threads of a
271 tracked process each time they are scheduled on a CPU.
272 This is an experimental feature intended to help analyse the
273 dynamic behaviour of processes in the system.
274 It may incur substantial overhead if enabled.
275 The default is for this feature to be disabled.
277 Perform a symbol and file:line lookup for each address in each
278 callgraph and save the output to
282 that only resolves the first symbol in the graph, this resolves
283 every node in the callgraph, or prints out addresses if no
284 lookup information is available.
285 This option requires the
287 option to read in samples that were previously collected and
292 Set the cpus for subsequent system mode PMCs specified on the
297 is a comma separated list of CPU numbers, or the literal
299 denoting all available CPUs.
300 The default is to allocate system mode PMCs on all available
303 Toggle between process mode PMCs measuring events for the target
304 process' current and future children or only measuring events for
306 The default is to measure events for the target process alone.
307 (it has to be passed in the command line prior to
314 Specify that the gprof profile files will use a wide history counter.
315 These files are produced in a format compatible with
317 However, other tools that cannot fully parse a BSD-style
318 gmon header might be unable to correctly parse these files.
319 .It Fl f Ar pluginopt
320 Pass option string to the active plugin.
322 threshold=<float> do not display cost under specified value (Top).
324 skiplink=0|1 replace node with cost under threshold by a dot (Top).
326 Produce profiles in a format compatible with
328 A separate profile file is generated for each executable object
330 Profile files are placed in sub-directories named by their PMC
335 which you can get from
339 .It Fl k Ar kerneldir
340 Set the pathname of the kernel directory to argument
342 This directory specifies where
344 should look for the kernel and its modules.
345 The default is to use the path of the running kernel obtained from the
348 Modules will also be searched for in /boot/modules if not found in
351 Set system-wide performance measurement duration for
356 may be a fractional value.
358 Print the sampled PCs with the name, the start and ending addresses
359 of the function within they live.
362 argument is mandatory and indicates where the information will be stored.
367 this information is sent to the output file specified by the
370 This option requires the
372 option to read in samples that were previously collected and
377 Set the default sampling rate for subsequent sampling mode
378 PMCs specified on the command line.
379 The default is to configure PMCs to sample the CPU's instruction
380 pointer every 65536 events.
381 .It Fl o Ar outputfile
382 Send counter readings and textual representations of logged data
385 The default is to send output to
387 when collecting live data and to
389 when processing a pre-existing logfile.
390 .It Fl p Ar event-spec
391 Allocate a process mode counting PMC measuring hardware events
397 Set the top of the filesystem hierarchy under which executables
398 are located to argument
402 .It Fl s Ar event-spec
403 Allocate a system mode counting PMC measuring hardware events
406 .It Fl t Ar process-spec
407 Attach process mode PMCs to the processes named by argument
411 may be a non-negative integer denoting a specific process id, or a
412 regular expression for selecting processes based on their command names.
413 .It Fl u Ar event-spec
414 Provide short description of event.
418 Print the values of all counting mode PMCs or sampling mode PMCs
424 may be a fractional value.
425 The default interval is 5 seconds.
426 .It Fl z Ar graphdepth
427 When printing system-wide callgraphs, limit callgraphs to the depth
428 specified by argument
434 is specified, it is executed using
437 To perform system-wide statistical sampling on an AMD Athlon CPU with
438 samples taken every 32768 instruction retirals and data being sampled
442 .Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
446 and measure the number of data cache misses suffered
447 by it and its children every 12 seconds on an AMD Athlon, use:
448 .Dl "pmcstat -d -w 12 -p k7-dc-misses firefox"
450 To measure instructions retired for all processes named
453 .Dl "pmcstat -t '^emacs$' -p instructions"
455 To measure instructions retired for processes named
457 for a period of 10 seconds use:
458 .Dl "pmcstat -t '^emacs$' -p instructions sleep 10"
460 To count instruction tlb-misses on CPUs 0 and 2 on a Intel
461 Pentium Pro/Pentium III SMP system use:
462 .Dl "pmcstat -c 0,2 -s p6-itlb-miss"
464 To collect profiling information for a specific process with pid 1234
465 based on instruction cache misses seen by it use:
466 .Dl "pmcstat -P ic-misses -t 1234 -O /tmp/sample.out"
468 To perform system-wide sampling on all configured processors
469 based on processor instructions retired use:
470 .Dl "pmcstat -S instructions -O /tmp/sample.out"
471 If callgraph capture is not desired use:
472 .Dl "pmcstat -N -S instructions -O /tmp/sample.out"
474 To send the generated event log to a remote machine use:
475 .Dl "pmcstat -S instructions -O remotehost:port"
476 On the remote machine, the sample log can be collected using
478 .Dl "nc -l remotehost port > /tmp/sample.out"
482 compatible profiles from a sample file use:
483 .Dl "pmcstat -R /tmp/sample.out -g"
485 To print a system-wide profile with callgraphs to file
488 .Dl "pmcstat -R /tmp/sample.out -G foo.graph"
494 may issue the following diagnostic messages:
496 .It "#callchain/dubious-frames"
497 The number of callchain records that had an
499 value for a return address.
500 .It "#exec handling errors"
503 events in the log file that named executables that could not be
508 events that named ELF executables.
512 events that named executables with unrecognized formats.
514 The total number of samples in the log file.
515 .It "#samples/unclaimed"
516 The number of samples that could not be correlated to a known
517 executable object (i.e., to an executable, shared library, the
518 kernel or the runtime loader).
519 .It "#samples/unknown-object"
520 The number of samples that were associated with an executable
521 with an unrecognized object format.
526 Due to the limitations of the
530 compatible profiles generated by the
532 option do not contain information about calls that cross executable
536 files are also only meaningful for native executables.
549 utility first appeared in
554 .An Joseph Koshy Aq Mt jkoshy@FreeBSD.org
558 utility cannot yet analyse
560 logs generated by non-native architectures.