8.3. cputrack CommandWhile the cpustat command monitors activity for the entire system, the cputrack command allows the same counters to be measured for a single process. This can be useful for focusing on particular applications and determining whether only one process is the cause of performance issues. The event specification for cputrack is the same as cpustat, except that instead of an interval and a count, cputrack takes either a command or -p PID. # cputrack Usage: cputrack [-T secs] [-N count] [-Defhnv] [-o file] -c events [command [args] | -p pid] -T secs seconds between samples, default 1 -N count number of samples, default unlimited -D enable debug mode -e follow exec(2), and execve(2) -f follow fork(2), fork1(2), and vfork(2) -h print extended usage information -n suppress titles -t include virtualized %tick register -v verbose mode -o file write cpu statistics to this file -c events specify processor events to be monitored -p pid pid of existing process to capture Use cpustat(1M) to monitor system-wide statistics. The usage message for cputrack ends with a reminder to use cpustat for systemwide statistics. The following example demonstrates cputrack monitoring the instructions and cycles for a sleep command. # cputrack -c pic0=Instr_cnt,pic1=Cycle_cnt sleep 5 time lwp event pic0 pic1 1.024 1 tick 188134 629987 2.023 1 tick 0 0 3.023 1 tick 0 0 4.023 1 tick 0 0 5.023 1 tick 0 0 5.034 1 exit 196623 682808 In the first second, the sleep command initializes and executes 188, 134 instructions. Then the sleep command sleeps, reporting zero counts in the output; this shows that cputrack is monitoring our sleep command only and is not reporting on other system activity. The sleep command wakes after five seconds and executes the final instructions, finishing with the total on exit of 196, 623 instructions. As another example, we use cputrack to monitor the D-cache activity of PID 19849, which has multiple threads. The number of samples is limited to 20 (-N). $ cputrack -N 20 -c pic0=DC_access,pic1=DC_miss -p 19849 time lwp event pic0 pic1 1.007 1 tick 34543793 824363 1.007 2 tick 0 0 1.007 3 tick 1001797338 5153245 1.015 4 tick 976864106 5536858 1.007 5 tick 1002880440 5217810 1.017 6 tick 948543113 3731144 2.007 1 tick 15425817 745468 2.007 2 tick 0 0 2.014 3 tick 1002035102 5110169 2.017 4 tick 976879154 5542155 2.030 5 tick 1018802136 5283137 2.033 6 tick 1013933228 4072636 ...... This CPU type provides D-cache misses for pic1, a useful statistic inasmuch as cache misses incur a certain time cost. Here, lwp 2 appears to be idle, while lwps 3, 4, 5, and 6 are causing many D-cache events. With a little awk, we could add another column for D-cache hit ratio. For additional information on cputrack, see cputrack(1). |