Next: Profiling, Previous: General Efficiency Hints, Up: Advanced Compiler Use and Efficiency Hints [Contents][Index]
Efficiency notes are messages that warn the user that the compiler has chosen a relatively inefficient implementation for some operation. Usually an efficiency note reflects the compiler’s desire for more type information. If the type of the values concerned is known to the programmer, then additional declarations can be used to get a more efficient implementation.
Efficiency notes are controlled by the
extensions:inhibit-warnings
(see optimize-declaration)
optimization quality. When speed
is greater than
extensions:inhibit-warnings
, efficiency notes are enabled.
Note that this implicitly enables efficiency notes whenever
speed
is increased from its default of 1
.
Consider this program with an obscure missing declaration:
(defun eff-note (x y z) (declare (fixnum x y z)) (the fixnum (+ x y z)))
If compiled with (speed 3) (safety 0)
, this note is given:
In: DEFUN EFF-NOTE (+ X Y Z) ==> (+ (+ X Y) Z) Note: Forced to do inline (signed-byte 32) arithmetic (cost 3). Unable to do inline fixnum arithmetic (cost 2) because: The first argument is a (INTEGER -1073741824 1073741822), not a FIXNUM.
This efficiency note tells us that the result of the intermediate
computation (+ x y)
is not known to be a fixnum
, so
the addition of the intermediate sum to z
must be done less
efficiently. This can be fixed by changing the definition of
eff-note
:
(defun eff-note (x y z) (declare (fixnum x y z)) (the fixnum (+ (the fixnum (+ x y)) z)))
Next: Profiling, Previous: General Efficiency Hints, Up: Advanced Compiler Use and Efficiency Hints [Contents][Index]