Chapter 8. Code Tuning
La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever.(Perfection is attained not when there is nothing left to add, but when there is nothing more to take away.)
The art of writing software tuned for maximum performance is a difficult one to learn, much less master; it could easily be the topic of a book all to itself. However, operating system tuning can only get you so far: poorly optimized software can be a bottleneck just as easily as a shortage of physical memory. In these cases, if you have access to the application’s source code, some careful tuning can help you solve the performance problem. Generally, performance problems in software fall into two broad areas: poor algorithm selection and inefficient implementation.
In this chapter, I discuss the two most critical optimizations for system performance, some techniques for analyzing application performance (such as the Solaris trace normal form (TNF) probe facility and the GNU profiling tool gprof ), and some common patterns that lend themselves to optimization.
The Two Critical Approaches
There are two exceptionally valuable approaches for improving the performance of your applications. The first of these is to write refactored code. Refactoring is a process that originated out of the Smalltalk and academic programming communities, and that emphasizes clear, concise programming, as well as automated testing. When code ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access