25 Performance
25 Performance
Performance Analysis
Computer Center, CS, NCTU
What you can do to improve performance
2
Computer Center, CS, NCTU
Factors that affect Performance
3
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing CPU usage (1)
4
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing CPU usage (2)
vmstat command
• Report kernel statistics about process, memory, cpu, ..
• Usage: % vmstat –c 2 –w 1
us: user time
– High us means high computation
sy: system time
– High sy means process are making lots of system call or performing I/O
id: cpu idle
• us and sy time should half-half
• Monitoring interval should not be too small
tytsai@u3:/var/log> vmstat –c 2 –w 5
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr da0 da1 in sy cs us sy id
3 2 0 50364 1587316 3 0 0 0 3 0 0 0 931 786 181 0 0 100
0 2 0 50368 1587312 5 0 0 0 0 0 0 0 250 91 23 0 0 99
5
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing CPU usage (3)
Nothing to do Server
tytsai@u3:/var/log> vmstat –c 2 –w 5
procs memory page disks faults cpu
rbw avm fre flt re pi po fr sr da0 da1 in sy cs us sy id
3 2 0 50364 1587316 3 0 0 0 3 0 0 0 931 786 181 0 0 100
0 2 0 50368 1587312 5 0 0 0 0 0 0 0 250 91 23 0 0 99
Load average
• The average number of runnable processes
Including processes waiting for disk or network I/O
uptime command
• Show how long system has been running and the load average
of the system over the last 1, 5, and 15 minutes
• Usage: % uptime
{tytsai@mgate2}~> uptime
8:22AM up 6 days, 22:13, 2 users, load averages: 0.06, 0.02, 0.00
7
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing CPU usage (5)
top command
• Display and update information about the top cpu processes
ps command
• Show process status
renice command
• renice –n increment –p pid
• renice +1 987 –u daemon root –p 32
8
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing memory usage (1)
9
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing memory usage (2)
pstat command
• % pstat -s
csduty[~] -chiahung- pstat -s
Device 1K-blocks Used Avail Capacity
/dev/label/swap-0 1048572 0 1048572 0%
/dev/label/swap-1 1048572 0 1048572 0%
Total 2097144 0 2097144 0%
10
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing memory usage (3)
vmstat command
• procs
r: in run queue
b: blocked for resource
w: runnable or short sleeper but swapped
• memory
avm: active virtual pages
fre: size of the free list
• page (averaged each five seconds, given in units per second)
flt: total number of page faults
pi: pages paged in
po: pages paged out
– 50 page-out cause about 1 seconds latency
fr: pages freed per second
csws1[~] -chiahung- vmstat -c 3 -w 5
procs memory page disks
rbw avm fre flt re pi po fr sr da0 da1
030 1427M 1196M 224 0 0 0 312 0 0 0
030 1427M 1196M 3 0 0 0 169 0 12 12
11 030 1427M 1196M 3 0 0 0 110 0 15 15
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing disk I/O
iostat command
• Report I/O statistics
• Usage: iostat –w 1 –c 5
tin/tout: characters read from /write to terminal
KB/t: kilobytes per transfer
tps: transfers per second
MB/s: megabytes per second
12
Computer Center, CS, NCTU
System Performance Checkup –
Analyzing network
13
Computer Center, CS, NCTU
systat
display system statistics
/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10
Load Average ||
systat -vmstat |
===>
| | | | | | | | | | daefr ahc1 irq25
764 prcfr 2000 cpu0: time
29 dtbuf 18391 totfr 876 em0 irq256
Namei Name-cache Dir-cache 450000 desvn react 4 em1 irq257
Calls hits % hits % 395311 numvn pdwak 2000 cpu1: time
154838 144273 93 25000 frevn pdpgs 2000 cpu2: time
intrn 2000 cpu3: time
Disks ad4 ad6 ad8 ad10 da0 pass0 3917836 wire 2000 cpu5: time
KB/t 104 0.00 107 0.00 61.70 0.00 4763576 act 2000 cpu7: time
tps 22 0 31 0 775 0 2908320 inact 2000 cpu4: time
MB/s 2.24 0.00 3.24 0.00 46.71 0.00 109544 cache 2000 cpu6: time
14 %busy 2 0 3 0 82 0 471700 free
327552 buf
Computer Center, CS, NCTU
*stat commands
15
Computer Center, CS, NCTU
top
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
26091 squid 17 44 0 414M 384M ucond 1 35:51 0.00% squid
11945 bind 11 44 0 71696K 59544K select 1 32:06 0.00% named
11375 root 1 58 0 20960K 3144K select 1 9:35 0.00% sshd
68517 nobody 1 44 0 24472K 14716K select 3 8:00 0.00% rsync
top –m io
last pid: 9347; load averages: 0.21, 0.29, 0.32 up 17+09:58:20 13:58:16
243 processes: 1 running, 242 sleeping
CPU states: 0.5% user, 0.0% nice, 1.2% system, 0.0% interrupt, 98.3% idle
Mem: 2200M Active, 7484M Inact, 1604M Wired, 25M Cache, 214M Buf, 562M Free
Swap: 2048M Total, 140K Used, 2048M Free
PID USERNAME VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND
18107 cvsup 0 0 0 0 0 0 0.00% cvsupd
26091 squid 34 0 0 0 0 0 0.00% squid
11945 bind 9 3 0 0 0 0 0.00% named
11375 root 4 0 0 0 0 0 0.00% sshd
16
Computer Center, CS, NCTU
gstat
L(q) ops/s r/s kBps ms/r w/s kBps ms/w %busy Name
0 0 0 0 0.0 0 0 0.0 0.0| acd0
5 218 218 15756 9.3 0 0 0.0 94.0| da0
0 111 2 214 5.0 107 933 4.3 23.4| ad4
0 113 0 0 0.0 111 933 4.3 24.1| ad5
0 111 2 214 5.0 107 933 4.3 23.5| ad4s1
0 113 0 0 0.0 111 933 4.3 24.1| ad5s1
0 0 0 0 0.0 0 0 0.0 0.0| ad6
0 5 0 0 0.0 5 40 0.6 0.3| ad4s1a
0 0 0 0 0.0 0 0 0.0 0.0| ad4s1b
0 0 0 0 0.0 0 0 0.0 0.0| ad4s1c
0 106 2 214 5.0 102 893 4.7 23.4| ad4s1d
0 0 0 0 0.0 0 0 0.0 0.0| ad7
0 5 0 0 0.0 5 40 0.3 0.1| ad5s1a
0 0 0 0 0.0 0 0 0.0 0.0| ad5s1b
0 0 0 0 0.0 0 0 0.0 0.0| ad5s1c
0 108 0 0 0.0 106 893 4.7 24.1| ad5s1d
0 4 0 0 0.0 4 40 0.8 0.3| mirror/gm0s1a
17