Newsgroups: comp.lang.clos
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!howland.reston.ans.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!newsfeed.pitt.edu!dbisna.com!psinntp!psinntp!psinntp!psinntp!halon!sybase!tenny
From: tenny@sybase.com (David Tenny)
Subject: CLOS performance (was Re: Lisp considered too hard)
Message-ID: <DBBGKM.IEC@sybase.com>
Sender: usenet@sybase.com
Organization: Sybase, Inc.
References: <3t8kjm$qkk@info.epfl.ch> <9507051740.AA18360@pharlap.ci.com>
Date: Thu, 6 Jul 1995 22:45:57 GMT
Lines: 60

In article <9507051740.AA18360@pharlap.ci.com>, you write:
|> In article <3t8kjm$qkk@info.epfl.ch>, Stefan Monnier writes:
|> 
|> |> I do use CL but I must admit that CLOS, though nifty, is a dog: I always find
|> |> myself using defstruct to overcome the performance problems of defclass.
|> 
|> Which particular CLOS implementation are you referring to?
|> 
|> David Kuznick - david@ci.com (preferred) or dkuznick@world.std.com

I use Franz Inc's Allegro CL for Windows.  A pretty nifty product overall.

Not being a CLOS wiz, I can't say what other systems do, but CLOS
object instantiation and slot overhead in ACL seems horrible to me.

In some benchmarks that I ran on ACL 2.0, (a while ago, and I don't
have the exact numbers or code around any more), I recall that
CLOS object instantiation via MAKE-INSTANCE was *27* times slower
than defstruct instantiation with BOA constructors.  Adding insult to
injury is the fact that all CLOS instances appear to have an overhead
of FOUR slots (presumably to support MOP, etc..).  

My application creates thousands of object instances
and has to save and restore them to disk in printable/readable form. Performance
is important enough that I avoid CLOS for the objects which have large
numbers of instances and don't really require fancy CLOS stuff.
So far, this means that only about 5% of my types are DEFSTRUCT instead
of DEFCLASS.  However the code isn't in production, and I haven't seen
yet where I'm really going to get smashed by using CLOS objects, if at all.

If all it required was simply DEFSTRUCT vs. DEFCLASS in my code,
this wouldn't be annoying.  But I had to spend some time coming up
with a bunch of fancy macros to define objects for persistent use
while switch hitting between DEFSTRUCT and DEFCLASS as appropriate,
and generally giving me some degree of transparency/abstraction
in DEFSTRUCT vs. DEFCLASS use.

My idea of an acceptable performance penalty for CLOS objects
would be something like 5x instantiation cost, and 2-SLOT overhead.
27x and 4-slot overhead seems rediculous.  (Again, being CLOS impaired,
I don't understand why there's anything more than a ONE slot overhead
for CLOS instances).

Okay, I'm done whining.  
Summary: CLOS is good.  DEFSTRUCT is necessary.  I can't have it all, yet.
Question: Is ACL's CLOS performance bad?   Or is this typical and acceptable?

-- 
------------------------------------------------------------------------------

Dave Tenny

Company:	Sybase, Inc.
Email:		tenny@sybase.com
Phone:		617-564-7952
Fax:		617-564-7960

Sybase, Inc
2 Burlington Woods Office Park
Burlington, MA. 01803
