Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (7229 KB)
cputrack(1)Name | Synopsis | Description | Options | Usage | Examples | Warnings | Attributes | See Also Name
Synopsis
cputrack -c eventspec [-c eventspec]... [-efntvD]
[-N count] [-o pathname] [-T interval] command [args]
cputrack -c eventspec [-c eventspec]... -p pid [-efntvD]
[-N count] [-o pathname] [-T interval]
cputrack -h DescriptionThe cputrack utility allows CPU performance counters to be used to monitor the behavior of a process or family of processes running on the system. If interval is specified with the -T option, cputrack samples activity every interval seconds, repeating forever. If a count is specified with the -N option, the statistics are repeated count times for each process tracked. If neither are specified, an interval of one second is used. If command and optional args are specified, cputrack runs the command with the arguments given while monitoring the specified CPU performance events. Alternatively, the process ID of an existing process can be specified using the -p option. Because cputrack is an unprivileged program, it is subject to the same restrictions that apply to truss(1). For example, setuid(2) executables cannot be tracked. Options
The following options are supported: UsageThe operating system enforces certain restrictions on the tracing of processes. In particular, a command whose object file cannot be read by a user cannot be tracked by that user; set-uid and set-gid commands can only be tracked by a privileged user. Unless it is run by a privileged user, cputrack loses control of any process that performs an exec() of a set-id or unreadable object file. Such processes continue normally, though independently of cputrack, from the point of the exec(). The system may run out of per-user process slots when the -f option is used, since cputrack runs one controlling process for each process being tracked. The times printed by cputrack correspond to the wallclock time when the hardware counters were actually sample. The time is derived from the same timebase as gethrtime(3C). The cputrack utility attaches performance counter context to each process that it examines. The presence of this context allows the performance counters to be multiplexed between different processes on the system, but it cannot be used at the same time as the cpustat(1M) utility. Once an instance of the cpustat utility is running, further attempts to run cputrack will fail until all instances of cpustat terminate. Sometimes cputrack provides sufficient flexibility and prints sufficient statistics to make adding the observation code to an application unnecessary. However, more control is occasionally desired. Because the same performance counter context is used by both the application itself and by the agent LWP injected into the application by cputrack, it is possible for an application to interact with the counter context to achieve some interesting capabilities. See cpc_enable(3CPC). The processor cycle counts enabled by the -t option always apply to both user and system modes, regardless of the settings applied to the performance counter registers. The output of cputrack is designed to be readily parseable by nawk(1) and perl(1), thereby allowing performance tools to be composed by embedding cputrack in scripts. Alternatively, tools may be constructed directly using the same APIs that cputrack is built upon, using the facilities of libcpc(3LIB) and libpctx(3LIB). See cpc(3CPC). Although cputrack uses performance counter context to maintain separate performance counter values for each LWP, some of the events that can be counted will inevitably be impacted by other activities occurring on the system, particularly for limited resources that are shared between processes (for example, cache miss rates). For such events, it may also be interesting to observe overall system behavior with cpustat(1M). For the -T interval option, if interval is specified as zero, no periodic sampling is performed. The performance counters are only sampled when the process creates or destroys an LWP, or it invokes fork(2), exec(2), or exit(2). ExamplesSPARCExample 1 Using Performance Counters to Count Clock CyclesIn this example, the utility is being used on a machine containing an UltraSPARC-III+ processor. The counters are set to count processor clock cycles and instructions dispatched in user mode while running the sleep(1) command.
Example 2 Counting External Cache References and MissesThis example shows more verbose output while following the fork() and exec() of a simple shell script on an UltraSPARC machine. The counters are measuring the number of external cache references and external cache misses. Notice that the explicit pic0 and pic1 names can be omitted where there are no ambiguities.
x86Example 3 Counting InstructionsThis example shows how many instructions were executed in the application and in the kernel to print the date on a Pentium III machine:
Example 4 Counting TLB HitsThis example shows how to use processor-specific attributes to count TLB hits on a Pentium 4 machine:
WarningsBy running any instance of the cpustat(1M) utility, all existing performance counter context is forcibly invalidated across the machine. This may in turn cause all invocations of the cputrack command to exit prematurely with unspecified errors. If cpustat is invoked on a system that has CPU performance counters which are not supported by Solaris, the following message appears:
This error message implies that cpc_open() has failed and is documented in cpc_open(3CPC). Review this documentation for more information about the problem and possible solutions. If a short interval is requested, cputrack may not be able to keep up with the desired sample rate. In this case, some samples may be dropped. AttributesSee attributes(5) for descriptions of the following attributes:
See Alsonawk(1), perl(1), proc(1), truss(1), prstat(1M), cpustat(1M), exec(2), exit(2), fork(2), setuid(2), vfork(2), gethrtime(3C), strtoll(3C), cpc(3CPC), cpc_bind_pctx(3CPC), cpc_enable(3CPC), cpc_open(3CPC), libcpc(3LIB), libpctx(3LIB), proc(4), attributes(5) Name | Synopsis | Description | Options | Usage | Examples | Warnings | Attributes | See Also |
||||||||||||