[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: following up on speed

> Date: Wed, 17 Jul 2002 08:57:29 -0400
> From: Adam Turoff <ziggy@panix.com>
> Cc: ll1-discuss@ai.mit.edu
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> User-Agent: Mutt/1.4i
> Sender: owner-ll1-discuss@ai.mit.edu
> Precedence: bulk
> On Wed, Jul 17, 2002 at 12:43:22AM -0400, Daniel Weinreb wrote:
> > >Actually, I think it would be fair. In my experience, many C/C++ coders
> > >don't seem to think too much about allocation issues.
> >
> > Well, OK. One must be careful about exactly what one is trying to 
> > measure and what question one is trying to answer.
> Yep.  
> Comparing a program using best-in-class GC with Scheme against the
> default malloc/free in C is fair for comparing average case
> performance with typical Scheme/C programmers.  That would be more
> informative than benchmarking theoretical maximum performance in
> Scheme or C.
> The important difference here is that the Scheme programmer uses 
> a GC that benefits from decades of research without thinking about it,
> while the C programmer must spend time tweaking or replacing the default
> malloc implementation.
> It might be more reasonable to test something like PLT Scheme against
> a good C compiler using Boehm's GC.  In my experience, C projects
> using Boehm are few and far between, so that's not a good basis for 
> comparison in the average case.
> Z.

One other issue is that in languages without GC, the programmer usually
tries to avoid allocation as much as possible, because it's such a pain to
keep track of memory.  In contrast, in languages with GC, it's easy to
write functions that use data structures that need heap allocation
(e.g. using a linked list in scheme where a C programmer would use arrays).
That's one reason it's difficult to compare costs.  Malloc may be really
slow in C, much slower than GC, but if the programmer only uses it to
allocate a few data structures at the beginning of a program, then the cost
may be minimal, in constrast to a scheme programmer who is doing heavy
consing in most of his functions.  OTOH the lack of GC discourages C
programmers from using anything other than trivial data structures; I'd
argue that this is a huge cost in terms of code complexity which dwarfs the
efficiency costs of GC.