‏הצגת רשומות עם תוויות CPU. הצג את כל הרשומות
‏הצגת רשומות עם תוויות CPU. הצג את כל הרשומות

יום ראשון, 16 ביוני 2013

How to generate CPU load?


Sometimes, system administrators are asked to generate 'dummy' load on CPU to test the load vs performance. Here is a short example which shows how to generate load per CPU or per Core basis (actually threads):



 # perl -e 'while (--$ARGV[0] and fork) {}; while () {}' 4


The last digit "4" in this case indicates how many CPUs or threads or cores you want to load by this method. This indeed is a good idea to test the CPU performance when some of the threaded/virtual CPUs are loaded.

When I gave the above command, in other terminal window for same server, I can observe something like this:

# mpstat 5
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0    0   0   10   213  105   17    0    0    0    0    38    0   2   0  98
  1    0   0    0     1    0    0    0    0    0    0     0    0   0   0 100
  2    0   0    0     2    0    2    0    0    0    0     0    0   0   0 100
  3    0   0    0     1    0    0    0    0    0    0     0    0   0   0 100
  4    0   0    0     2    0    2    0    0    0    0     5    0   0   0 100
  5    0   0    3     4    0    6    0    0    0    0     0    0   0   0 100
  6    0   0    1    13    6   11    0    0    0    0     0    0   0   0 100
  7    0   0    4     3    0    4    0    0    0    0    10    0   0   0 100
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0   21   7  139   227  118   18    9    0    1    0    53   85   1   0  14
  1    4   0    7     9    0   16    0    4    0    0     4    1   1   0  98
  2   10   0    0     8    0    5    5    0    1    0     1   85   0   0  15
  3    0   1   34     7    0   11    0    1    0    0     3    0   0   0 100
  4    6   0    0     6    0    2    4    0    0    0     4   84   0   0  16
  5    7   0    0     2    0    1    0    1    1    0     1    0   0   0 100
  6   10   0    4    12    5    3    5    0    0    0     1   85   0   0  15
  7    0   0   21    16    0   31    0    0    0    0    10    0   0   0 100
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0    0   0   30   207  106    0    8    0    0    0     0  100   0   0   0
  1    0   0    0     9    0   15    0    1    0    0    23    0   1   0  99
  2    0   0    0     6    0    0    5    0    0    0     0  100   0   0   0
  3    0   0    3     8    0   13    0    1    0    0    12    0   0   0 100
  4    0   0    0     6    0    0    5    0    0    0     0  100   0   0   0
  5    0   0    0     2    0    0    0    0    0    0     0    0   0   0 100
  6    0   0    1    10    3    2    7    0    0    0     0  100   0   0   0
  7    0   0    0     1    0    0    0    0    0    0     0    0   0   0 100
^C


The 'top' command output in this case will look like following:
# top
last pid:   698;  load avg:  1.61,  0.44,  0.19;       up 25+19:31:24                                                                             10:59:01
34 processes: 29 sleeping, 5 on cpu
CPU states: 49.8% idle, 50.0% user,  0.2% kernel,  0.0% iowait,  0.0% swap
Memory: 8192M phys mem, 6680M free mem, 4099M total swap, 4099M free swap

   PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
   694 root       1   0    0 6368K 3256K cpu/0    0:35 12.50% perl
   696 root       1   0    0 6360K 1672K cpu/7    0:35 12.45% perl
   697 root       1   0    0 6360K 1672K cpu/1    0:35 12.45% perl
   695 root       1   0    0 6360K 1800K cpu/6    0:35 12.14% perl
   698 root       1  59    0 2944K 2104K cpu/3    0:00  0.03% top
   679 root       1  59    0   10M 3576K sleep    0:00  0.00% sshd
   119 root      24  59    0 4576K 4232K sleep    1:25  0.00% nscd
     9 root      15  59    0   10M 9704K sleep    0:42  0.00% svc.configd
   238 root       4  59    0 7888K 4664K sleep    0:29  0.00% inetd
     7 root      12  59    0   13M 9904K sleep    0:34  0.00% svc.startd
   302 root      16  59    0   15M 9400K sleep    0:27  0.00% fmd
   202 root       1  59    0 1360K 1176K sleep    0:04  0.00% utmpd
   183 daemon     1  59    0 2848K 2360K sleep    0:11  0.00% rpcbind
   253 root       3  59    0 7464K 3160K sleep    0:08  0.00% automountd
     1 root       1  59    0 2512K 1920K sleep    0:05  0.00% init