property list hack, profiling, compiler optimization, looking at code
Subject: property list hack, profiling, compiler optimization, looking at code
From: Richard Fateman
Date: Sat, 11 Aug 2012 11:11:05 -0700
An additional observation regarding speed and zerop1, which is defined
this way:
(defun zerop1 (x)
(or (and (integerp x) (= 0 x))
(and (floatp x) (= 0.0 x))
(and ($bfloatp x) (= 0 (second x)))))
It could be "optimized" by adding a declaration this way:
(defun zerop1 (x) (declare (optimize (speed 3)(safety 0)))
(or (and (integerp x) (= 0 x))
(and (floatp x) (= 0.0 x))
(and ($bfloatp x) (= 0 (second x)))))
or the declaration could be placed on the whole file (zeropi is defined
in source code file simp.lisp).
What changes if optimization (speed=3) is set?
1. The code is 221 bytes rather than 258 bytes long
2. The code no longer check for wrong number of arguments, stack
overflow, or pending interrupts.
3. (I suspect) the typical use, of testing an integer to see if it is
zero or not, is reduced from
about 15 instructions to 10 instructions. Your compiler/assembler/CPU/
may differ.
I don't know if the optimization settings of the different lisps is
equivalent when people
publish "times to execute the test suite". What is fair? Perhaps to set
to the highest
optimization for which the test suite runs? Perhaps to set to some
optimization level
for which keyboard interrupts still work? Clearly a lisp that saves
extra debugging info
is at a timing disadvantage in timing tests.
RJF