I'm using 8.3 on a 3650 (at home!), and I found the following slightly
unfortunate performance issue:
If I define a class with accessors for its slots:
(defclass fibly ()
((s1 :accessor fibly-s1)))
Then calling FIBLY-S1 inside a method is extremely (well, byt the
standards of the machine) fast -- pretty much as good as using the
slot directly.
*But* If I define some auxilliary method on FIBLY-S1:
(defmethod fibly-s1 :after ((f fibly))
... check something about the slot or something, or even
empty ...)
Then performance is catastrophically worse (something like a 20-30x
hit). If I defined the accessor manually:
(defclass fibly ()
((s1)))
(defmethod fibly-s1 ((f fibly))
(slot-value f 's1))
then the difference in performance between the single-method case &
the primary-method + aux-method is a factor of 2 or something (and
the second case is much faster than the automatically-defined reader +
aux method case).
This is a real pain because it makes defining methods to check
consistency & stuff on accessors painful. Of course I'm not expecting
amazing performance from the machine, but this kind of slowdown makes
it hard to even test stuff I'm writing to take in to work later. I'm
quite willing to sacrifice the very fast best case for a less bad
slowdown if I can avoid having to define all my own methods for
accessors.
Does anyone know if there's anything that can be done about this, sort
of shadowing DEFCLASS and making it do something different with
accessors.
Thanks
--tim
Answering my own question: the system knows what methods are
automatically defined, and does magic inside the body of methods to
arrange for these things to compile into slot accesses prety much
directly, after doing some fast runtime check that there are no `user'
methods. If you define an auxiliary method it punts to a more general
case, and this is much slower than function call (and it conses).
Declaring the accessor NOTINLINE prevents the optimisation, and the
bad case with aux. methods.
It's nice having most of the the source code to browse....
--tim