1 .\" Copyright (c) 2003-2007 Joseph Koshy. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\" notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\" notice, this list of conditions and the following disclaimer in the
10 .\" documentation and/or other materials provided with the distribution.
12 .\" This software is provided by Joseph Koshy ``as is'' and
13 .\" any express or implied warranties, including, but not limited to, the
14 .\" implied warranties of merchantability and fitness for a particular purpose
15 .\" are disclaimed. in no event shall Joseph Koshy be liable
16 .\" for any direct, indirect, incidental, special, exemplary, or consequential
17 .\" damages (including, but not limited to, procurement of substitute goods
18 .\" or services; loss of use, data, or profits; or business interruption)
19 .\" however caused and on any theory of liability, whether in contract, strict
20 .\" liability, or tort (including negligence or otherwise) arising in any way
21 .\" out of the use of this software, even if advised of the possibility of
31 .Nd "performance measurement with performance monitoring hardware"
37 .Op Fl M Ar mapfilename
38 .Op Fl O Ar logfilename
39 .Op Fl P Ar event-spec
40 .Op Fl R Ar logfilename
41 .Op Fl S Ar event-spec
48 .Op Fl o Ar outputfile
49 .Op Fl p Ar event-spec
52 .Op Fl s Ar event-spec
53 .Op Fl t Ar process-spec
56 .Op Ar command Op Ar args
60 utility measures system performance using the facilities provided by
65 utility can measure both hardware events seen by the system as a
66 whole, and those seen when a specified set of processes are executing
68 If a specific set of processes is being targeted (for example,
71 option is specified, or if a command line is specified using
73 then measurement occurs till
75 exits, or till all target processes specified by the
77 options exit, or till the
79 utility is interrupted by the user.
80 If a specific set of processes is not targeted for measurement, then
82 will perform system-wide measurements till interrupted by the
87 can mix allocations of system-mode and process-mode PMCs, of both
88 counting and sampling flavors.
89 The values of all counting PMCs are printed in human readable form
90 at regular intervals by
92 The output of sampling PMCs may be configured to go to a log file for
93 subsequent offline analysis, or, at the expense of greater
94 overhead, may be configured to be printed in text form on the fly.
96 Hardware events to measure are specified to
98 using event specifier strings
100 The syntax of these event specifiers is machine dependent and is
104 A process-mode PMC may be configured to be inheritable by the target
105 process' current and future children.
107 The following options are available:
108 .Bl -tag -width indent
110 Toggle between showing cumulative or incremental counts for
111 subsequent counting mode PMCs specified on the command line.
112 The default is to show incremental counts.
114 Create files with per-program samples in the directory named
117 The default is to create these files in the current directory.
119 Toggle showing per-process counts at the time a tracked process
120 exits for subsequent process-mode PMCs specified on the command line.
121 This option is useful for mapping the performance characteristics of a
122 complex pipeline of processes when used in conjunction with the
125 The default is to not to enable per-process tracking.
126 .It Fl M Ar mapfilename
127 Write the mapping between executable objects encountered in the event
128 log and the abbreviated pathnames used for
132 If this option is not specified, mapping information is not written.
137 in which case this mapping information is sent to the output
138 file configured by the
141 .It Fl O Ar logfilename
142 Send logging output to file
147 .Ar hostname Ns : Ns Ar port ,
150 does not start with a
156 will open a network socket to host
163 option is not specified and one of the logging options is requested,
166 will print a textual form of the logged events to the configured
168 .It Fl P Ar event-spec
169 Allocate a process mode sampling PMC measuring hardware events
172 .It Fl R Ar logfilename
173 Perform offline analysis using sampling data in file
175 .It Fl S Ar event-spec
176 Allocate a system mode sampling PMC measuring hardware events
180 Toggle logging the incremental counts seen by the threads of a
181 tracked process each time they are scheduled on a CPU.
182 This is an experimental feature intended to help analyse the
183 dynamic behaviour of processes in the system.
184 It may incur substantial overhead if enabled.
185 The default is for this feature to be disabled.
187 Set the cpus for subsequent system mode PMCs specified on the
192 is a comma separated list of CPU numbers, or the literal
195 The default is to allocate system mode PMCs on all CPUs.
197 Toggle between process mode PMCs measuring events for the target
198 process' current and future children or only measuring events for
200 The default is to measure events for the target process alone.
202 Produce flat execution profiles in a format compatible with
204 A separate profile file is generated for each executable object
206 Profile files are placed in sub-directories named by their PMC
208 .It Fl k Ar kerneldir
209 Set the pathname of the kernel directory to argument
211 This directory specifies where
213 should look for the kernel and its modules.
217 Set the default sampling rate for subsequent sampling mode
218 PMCs specified on the command line.
219 The default is to configure PMCs to sample the CPU's instruction
220 pointer every 65536 events.
221 .It Fl o Ar outputfile
222 Send counter readings and textual representations of logged data
225 The default is to send output to
227 .It Fl p Ar event-spec
228 Allocate a process mode counting PMC measuring hardware events
234 Set the top of the filesystem hierarchy under which executables
235 are located to argument
239 .It Fl s Ar event-spec
240 Allocate a system mode counting PMC measuring hardware events
243 .It Fl t Ar process-spec
244 Attach process mode PMCs to the processes named by argument
248 may be a non-negative integer denoting a specific process id, or a
249 regular expression for selecting processes based on their command names.
253 Print the values of all counting mode PMCs every
258 may be a fractional value.
259 The default interval is 5 seconds.
264 is specified, it is executed using
267 To perform system-wide statistical sampling on an AMD Athlon CPU with
268 samples taken every 32768 instruction retirals and data being sampled
272 .Dl "pmcstat -O sample.stat -n 32768 -S k7-retired-instructions"
276 and measure the number of data cache misses suffered
277 by it and its children every 12 seconds on an AMD Athlon, use:
278 .Dl "pmcstat -d -w 12 -p k7-dc-misses mozilla"
280 To measure processor instructions retired for all processes named
283 .Dl "pmcstat -t '^emacs$' -p instructions"
285 To count instruction tlb-misses on CPUs 0 and 2 on a Intel
286 Pentium Pro/Pentium III SMP system use:
287 .Dl "pmcstat -c 0,2 -s p6-itlb-miss"
289 To perform system-wide sampling on all configured processors
290 based on processor instructions retired use:
291 .Dl "pmcstat -S instructions -O /tmp/sample.out"
293 To send the generated event log to a remote machine use:
294 .Dl "pmcstat -S instructions -O remotehost:port"
295 On the remote machine, the sample log can be collected using
297 .Dl "nc -l remotehost port > /tmp/sample.out"
301 compatible flat profiles from a sample file use:
302 .Dl "pmcstat -R /tmp/sample.out -g"
317 utility first appeared in
322 .An Joseph Koshy Aq jkoshy@FreeBSD.org
326 utility cannot yet analyse
328 logs generated by non-native architectures.