[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a question about an efficiency tradeoff with flavors
I have a question about an efficiency tradeoff with flavors.
Say I have a flavor F with a readable instance variable I.
(defflavor F (I) () (:readable-instance-variables I))
Now say I want to write a function G which takes an instance of
F and returns some function H of its instance variable I. I
have two choices:
(defun G (F) (H (I F)))
(defmethod (G F) () (H I))
For the first, the funcall overhead is less but the cost of accessing
the instance variable is greater. For the second the opposite is
true. Presumably if there are only a few instance variable accesses, the
first is more efficient. How many accesses do there have to be to make the
second alternative more efficient. What I really want to know is what
is the cost of a function call vs. a generic function call (and how does
this depend on various things like the arglist complexity, the method
combination, the number of different flavors which implement a given
generic function, whether the method is directly on the flavor or is
inherited, etc.) as well as the cost of an instance variable access
vs. accessor function call.
I know that I could meter it but before I did so I was wondering
if someone knew the answer offhand. Also, someone might know
the analytical model behind the behavior.
1. What about :writable-instance-variables ?
(defflavor F (I) () (:writable-instance-variables I))
(defun G! (F x) (setf (I F) (H x)))
(defmethod (G! F) (x) (setf I (H x)))
2. How does the tradeoff differ on 36xx vs. Ivory?
3. The analogous capabilities exist in CLOS (though I am
not familiar with the details). How does the tradeoff differ
Thanks in advance for shedding any light on this issue,