Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!usc!snorkelwacker!think!kulla!barmar From: barmar@kulla (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: CLOS speed Message-ID: <31074@news.Think.COM> Date: 26 Oct 89 03:03:35 GMT References: <18769@pasteur.Berkeley.EDU> <31037@news.Think.COM> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 29 In article mujica@ra.cs.ucla.edu (S. Mujica) writes: >What about setting the value of a slot? I have noticed that running >PCL on Lucid 3.0, it takes about 30 times longer to set the value of >a slot than to set the value of local variable. Accessing a local variable is probably the fastest single operation in any Lisp implementation. CLOS slots should be compared with DEFSTRUCT slots, not with local variables. I'm sure it will still be much slower in PCL, but that's because it does no optimization. PCL's simplistic implementation of SLOT-VALUE makes a number of function calls; (SLOT-VALUE object 'slot) calls (SLOT-VALUE-USING-CLASS (CLASS-OF object) object 'slot), which has to do some table lookup to figure out where that slot is in that class. In a high performance implementation, with type declarations and block compilation, the offset can be determined at compile time, and most of the above can be compiled away or inlined. Note, by the way, that compilers that can provide the kind of performance I've been talking about probably won't be around for a while. CLOS is designed to permit this kind of optimization, but no one ever said that implementing such optimizers would be easy. This is very new stuff, so there's probably still some compiler research necessary. Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar