
マルチスレッド データベース サーバーのパフォーマンスを調査しています。特定のマシンで約 61 秒で実行される特定のワークロードがあります。ワークロードに対して perf を実行したとき、データベース プロセスの pid は 79894 でした。
データベース サーバーのソフトウェア スレッドに加えて、アイドル システムでは通常休止状態になっているが、ワークロードの実行中にアクティブになる Linux 関連のスレッドが多数あります。そのため、perf の -a オプションと -p オプションを使用する必要があります。
私は perf を 2 つの方法で実行しましたが、それぞれの方法で多少異なる結果が得られました。
最初の方法は、1つのウィンドウで次のperfコマンドを実行することです。
perf stat -p 2413 -a
そしてすぐに別のウィンドウでデータベースワークロードを実行します。データベースワークロードが終了すると、perfからCを制御して次の結果を取得します。
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
2番目の方法は、
perf stat -a sleep 61
1つのウィンドウでデータベースワークロードを実行し、すぐに別のウィンドウでデータベースワークロードを実行します。61秒後にperfとワークロードの両方が終了し、perfは次の結果を生成します。
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
両方のバージョンで -a を使用したため、ほぼ同じ結果が得られると予想しました。
しかし、睡眠によって、
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
2つの質問です。
(1) which set of results do I believe?
and
(2) how can there be more stalled-cycles-frontend than cycles in the sleep version?