Jan 15, 2015
Performance optimizaton on LinuxBy Peter Toth
Intro
What do you want to learn today?
What level are you interested in? Any specific requests? Have you ever optimized Linux or an application for Linux?
Assuming everyone is familiar with Linux concepts and basic architecture
Agenda
MethodologyKnow your…Optimisable hardware components
Methodology
DocumentStart on a clean systemEmpty caches - warmup cachesAutomate testing (clear caches every time)Step-by-stepKeep those changes which are significantEstablish baselineThink about side-effectsAvoid trial-and-error
Know your ...
ApplicationHardwareLinux (environment)
Application
Fix bugs! aka. optimize lastRun at least -O2Multi-threadingStructure the program to be efficient on the hardware and Linuxstructure size alignment (cache-line, IO)are all POSIX/OS features used?
If in doubt test!
Hardware
Select hardware for the taskStudy the hardware you’ve selected: CPU, HT, memory, NUMA, SSD, disks, iGPU, TDP/SDPTweak the SW for the HW (think SSE, AVX)Tune HW specifics through /sys
Linux
Linux interfaces
Run up-to-date (OS+gcc+libs)/proc - more OS/sys - more HWsysctlkernel command_linekernel configtop, ntop, iotopvmstat, iostatuname
Benchmark
consistent benchmarkingcomprehensive Linux application benchmarking: Phoronix Test Suite
Profiling
perfoprofilestracevalgrind
CPU/NUMA
CoresCaches (cache line size)Layout (physical to logical mapping)AffinityScheduling
I/O
Filesystem: ext4, xfs, btrfsScheduling: noop, cfq, deadlinehdparmqueues buffersIO block sizespinning media vs SSDAIO
Memory
page sizehuge pagesmadviseswappingpage cachememory overcommitingpage faultsmemory fragmentation
Power Management
consolidate old hw -> virtualizeschedulerpowertopturn off unused hardware (isolcpus, network)scheduler (use tickless)C statesP states: frequency-voltage combinations
Networking
Throughput or latency (RT Linux?) use your HWverify link speedssegmentation offloadnetwork buffersper socket bufferszero copyTCP congestion control algorithmstools: ethtool, iperf, netstat, wireshark!
Thank You!
Questions?