Linux Perf Tuning 2010 1up
Linux Perf Tuning 2010 1up
1
Logistics
3
Introduction to Performance
Tuning
Complex task that requires in-depth
understanding of hardware, software, and
application
If it were easy the OS would do it automatically (and
the OS does a lot automatically to begin with)
Goals of Performance Tuning
Speed up time to do a single large task (time to do
perform some large matrix calculation)
Graceful degredation of a web/application server as
it is asked to service a larger and larger number of
requests 4
Stress Testing
8
A basic performance tuning
methodology
Define your baseline configuration and
measure its performance
[ If appropriate, define a stress test workload, and
measure it. ]
Make a single change to the system
configuration. Measure the results of that
change and record it.
Repeat as necessary
Make sure to test single changes as well as
combination of changes. Sometimes effects are
synergistic 9
Basic Performance Tools
free
top
iostat
10
The free(1) command
11
Questions to ask yourself after
looking at free(1) output
Will adding more memory help?
Often the cheapest way to speed up server
If the system is using paging or swapping,
adding more physical memory may help
Will a larger page cache help?
More sophisticated tools will answer these
questions later...
But asking questions is the beginning of wisdom
12
The top(1) command
13
Questions to ask yourself when
looking at top(1) output
What are the top tasks running; should they
be there? Are they running? Waiting for disk?
How much memory are they taking up?
How is the CPU time (overall) being spent?
User time, System time, Niced user time, I/O Wait,
Hardware IRQ, Software IRQ, Stolen time
14
The iostat(1) command
15
Advanced iostat(1)
17
Example of iostat -xk 1
18
Conclusions we can draw from
the iostat results
Utilization: 98.48%
The system is I/O bound
Adding memory or speeding up the CPU clock
won't help
Solution attack the I/O bottleneck
Add more I/O bandwidth resources (use a faster
disk or use a RAID array)
Or, do less work!
19
Speeding up fs_mark
21
Comparing the two results
33.7
files/sec
2000
barrier
ops
49.2
files/sec
1000
barrier
ops
22
Before we leave fs_mark...
24
The snap script
26
File system and storage tuning
27
Hard Drives
Advantages of SSD
Fast random access reads
Fails usually when writing, not when reading
Less suceptible to mechanical shock/vibration
Most SSD's use less power than HDD's
Disadvantage of SSD's
Cost per Gb much more expensive
Limited number of write cycles
Writes are slower than reads; random writes can be
much slower (up to a ½ sec average, 2 sec worst 31
case for 4k random writes for really bad SSD's!)
Getting the right SSD is important
32
Should you use SSD's?
35
RAID tuning considerations
36
Filesystem Tuning
41
Network Tuning
Latency
When applications need maximum responsiveness
Lockstep protocols (i.e., no sliding window
optimizations)
RPC-based protocols
Throughput
When transfering large data sets
Very often tuning efforts will trade off latency for
throughput or vice versa
43
Interrupt Coalescing
46
Why the BDP matters
47
Using the BDP
57
NFS Performance tuning
58
Tuning a NFS Server
60
NFS client tuning
62
Agenda
63
Memory Tuning
64
To measure swapping activity
66
Optimizing swapping
67
Swapping vs. Paging
72
Interesting bits from sysrq-m
Per-zone statistics
73
About Memory Caches
78
Application Tuning
82
Back to C/C++ applications
86
System profiling using oprofile
87
Perf: the next generation
processor-related statistics
Conclusion
91