[plt-scheme] Polymorphic Structure Types
On Apr 22, Eli Barzilay wrote:
> Heh, this was the reason I thought it might not be a good idea to
> talk about this... But then again, this was the reason it was a
> good idea... Anyway, I'll have a look at it at some point in the
> future...
So on just a quick look, on my setup, your Swindle example is about 24
times slower than the records example... But this huge difference is
due to the fact that you're using generic functions, which have a big
overhead. When I remove the `show' generic and use `slot-ref' to
access slots, Swindle becomes "only" 4.5 times slower which makes more
sense (BTW, that's what I meant by saying that it is not as
heavyweight as you'd think -- avoiding methods).
Now, the reason that that's slower is because every reference does a
search for the position of the slot -- every class has a
`getters-n-setters' field that contains a specific getter/setter
function for each slot for the appropriate class. This is better for
complex hierarchies since you don't have to go through a chaing of
accessor functions.
Anyway, if I optimize an accessor function similar to yours (checking
the type manually, then using one of a fixed set of accessors), I get
a result which is still 3 times slower. So I guess more work on
optimizing this should be done, but that is a very delicate issue and
will take more time than I have now...
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!