Making Programs Faster
(Benchmarking, Profiling, and Performance Tuning)
Length: 3 hours
Prerequisites:
Students should have at least six months experience programming in Perl.
Description
Almost every application must be made to run faster; some sooner, some
later. Performance tuning of applications has long been a dark art,
understood by few and riddled with terrible pitfalls. Stories abound
of optimization projects that took weeks but yielded a pathetic 2%
decrease in total run time. Don't let this happen to you.
The class will begin with a brief introduction to the basic concepts
of performance tuning. We'll then take an extensive look at modules
for benchmarking and profiling and see several common blunders that
even experts commit when benchmarking. We'll finish with a discussion
of a few of the most important optimizations.
Throughout, the class will emphasize both high- and low-level
approaches to performance tuning: when to tune and when to try
something different; if tuning is necessary, how to focus your efforts
where they will do the most good. We'll learn how to rationally
evaluate programming situations and when to try alternative
approaches.
Outline
- Performance Tuning is Hard
- Schwartzian Transform
- Time
- user time + system time = CPU time
- "Optimizations"
- Wallclock Time
- I/O Bound Programs
- CPU Bound Programs
- Memory Bound Programs
- Simple Measurement Tools
- time()
- Time::HiRes
- times()
- Simple Benchmarker
- Benchmark.pm
- The Uncertainty Principle
- Performance Tuning Plan
- Profiling
- Case study: Mail Folder Analyzer
- Devel::DProf
- The 90-10 Rule
- Hot Spot: Mail::Header
- Mail Folder Analyzer Revisited
- When it's Time to Give Up
- The Big Picture
- POD Formatting
- perldoc
- pod2man
- Hot spot: Pod::Parser::parse_text
- Hot spot: Pod::ParseTree::append
- The Moment of Truth
- Devel::SmallProf
- smallprof.out
- Custom profiling tools
- The Perl debugger hooks
- Trivial Debugger
- Devel::OurProf
- ourprof.out
- Case study: XML processing turnaround
- Blunders
- Pseudo-Hashes
- The Missing 15%
- Getting the Wrong Answer as Quickly as Possible
- The Wrong Question
- Trivial Benchmarks
- 1+1=0
- File Editing
- Good Advice
- Premature Optimization
- Numerical Calculation
- Crappy Advice
- each vs. keys
- What to Remember
- Jackson's Rules
Samples
Sample slides coming soon. Watch this space.
Return to:
Universe of Discourse main page |
Perl Paraphernalia |
Classes and Talks
mjd-perl-yak+@plover.com