I'm investigating the performance of a multi-threaded database sever. There is a particular workload that runs in roughly 61 seconds on a particular machine. The pid of the database process was 79894 when I ran perf against the workload.
In addition to the software threads in the database server, there are a number of Linux related threads, which are normally dormant on an idle system, that become active while my workload is running. Thus I want to use the -a option of perf as well as the -p option.
I run perf in 2 ways and get somewhat different results with each way.
The first ways I run the following perf command in one window
perf stat -p 2413 -a
and immediately run the database workload in another window. When the database workload finishes, I control C out of perf and get the following results
Performance counter stats for process id '79894': 1,842,359.55 msec cpu-clock # 30.061 CPUs utilized 3,798,673 context-switches # 0.002 M/sec 153,995 cpu-migrations # 0.084 K/sec 16,038,992 page-faults # 0.009 M/sec 4,939,131,149,436 cycles # 2.681 GHz 3,924,220,386,428 stalled-cycles-frontend # 79.45% frontend cycles idle 3,418,137,943,654 instructions # 0.69 insn per cycle # 1.15 stalled cycles per insn 402,389,588,237 branches # 218.410 M/sec 5,137,510,170 branch-misses # 1.28% of all branches 61.28834199 seconds time elapsed
The second method is to run
perf stat -a sleep 61
in one window and immediately run the database workload in another window. After 61 seconds both perf and the workload finish and perf produces the following results
Performance counter stats for 'system wide': 4,880,317.67 msec cpu-clock # 79.964 CPUs utilized 8,274,996 context-switches # 0.002 M/sec 202,832 cpu-migrations # 0.042 K/sec 14,605,246 page-faults # 0.003 M/sec 5,022,298,186,711 cycles # 1.029 GHz 7,599,517,323,727 stalled-cycles-frontend # 151.32% frontend cycles idle 3,421,512,233,294 instructions # 0.68 insn per cycle # 2.22 stalled cycles per insn 402,726,487,019 branches # 82.521 M/sec 5,124,543,680 branch-misses # 1.27% of all branches 61.031494851 seconds time elapsed
Because I used -a in both versions, I expected to get roughly the same results.
But with sleep,
cpu-clock is 2.5 times what you get with the -p version, context-switches are double what you get with the -p version and the other values are more or less the same
So 2 questions,
(1) which set of results do I believe? and (2) how can there be more stalled-cycles-frontend than cycles in the sleep version?