LoginSignup
0
0

More than 3 years have passed since last update.

Linux性能分析

Last updated at Posted at 2021-02-09

Linux性能分析

まずはじめに

アーキテクチャを理解する

  • CPU、メモリ、ディスク、ネットワーク、マザーボード・・・
  • どこがボトルネックになっているか

CPU

  • top コマンド
  • sar コマンド

メモリ

ディスク

ネットワーク

CPU負荷をみてみる

  • テストプログラム

--- cpu.c ---
int main()
{
        while(1);
}

- コンパイル

# cc -o cpu cpu.c
# ls 
cpu cpu.c
※「cpu」が実行プログラム

- 実行

# ./cpu
  • CPU負荷状況の確認
# top
~~~
top - 21:42:42 up 23:56,  3 users,  load average: 0.34, 0.09, 0.07
Tasks: 169 total,   2 running, 167 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :★100.0 us,  0.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16222052 total,  5879608 free,  1028452 used,  9313992 buff/cache
KiB Swap:  4063228 total,  4063228 free,        0 used. 14847876 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
13588 root      20   0    4212    348    276 R 100.0  0.0   0:24.78 cpu★
13512 root      20   0   58420   2220   1524 R   0.3  0.0   0:00.91 top
    1 root      20   0  193928   7040   4180 S   0.0  0.0   0:04.45 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd
    4 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H
    6 root      20   0       0      0      0 S   0.0  0.0   0:00.44 ksoftirqd/0
    7 root      rt   0       0      0      0 S   0.0  0.0   0:00.17 migration/0

「cpu」プロセスが %CPU 100%利用して実行されています。
%CPUが100%とは1CPU(1論理CPU)のCPU使用率が100%で動いています。
ステータスはどういう状態でしょうか?
「S」の項目がプロセスの状態を示しています。
「R」なので「RUN」状態ですね。

  • CPU上でプロセスが実行されているイメージ

CPU利用イメージ.PNG

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0