LispWorks User Guide and Reference Manual > 9 The Compiler


9.6 Optimizing your code

Careful use of the compiler optimize qualities described above or special declarations may significantly improve the performance of your code. However it is not recommended that you simply experiment with the effect of adding declarations. It is more productive to work systematically:

  1. Use the Profiler, described in The Profiler, to analyse your application's performance and identify bottlenecks, then
  2. Consider whether re-writing of parts of your source code would improve efficiency at the bottlenecks, and
  3. Use :explain declarations to make the compiler generate optimization hints, and
  4. (In SMP LispWorks) use analysing-special-variables-usage to report on symbols proclaimed special, and
  5. Consider adding suitable declarations as described in this chapter to improve efficiency at the bottlenecks.

The most important tool for speeding up programs is the Profiler. You use the profiler to find the bottlenecks in the program, and then optimize these bottlenecks by helping the compiler to produce better code.

The remainder of this section describes some specific ways to produce efficient compiled code with LispWorks.

9.6.1 Compiler optimization hints

9.6.2 Fast 32-bit arithmetic

9.6.3 Floating point optimization

9.6.4 Tail call optimization

9.6.5 Usage of special variables

9.6.6 Stack allocation of objects with dynamic extent

9.6.7 Inlining foreign slot access

LispWorks User Guide and Reference Manual - 22 Dec 2009