[Shootout-list] Garbage Collection to improve efficiency was Re: Stuff

skaller skaller@users.sourceforge.net
26 Apr 2005 09:31:07 +1000


On Tue, 2005-04-26 at 04:03, Shae Matijs Erisson wrote:
> Pascal Obry <pascal@obry.net> writes:
> 
> > I certainly do not agree. A garbage collector is certainly slower than a
> > simple hand-written reference counter. And I don't see why a garbage
> > collector would make an algorithm implementation faster !!!!
> 
> There's also region allocation which is faster than manual step-by-step
> allocation because you can prove at compile time that a large contiguous chunk
> of memory can be deallocated all at once when a certain computation finishes.

Ocaml GC on small programs is even faster. 
Allocation is sequential within a region without a bound test, 
and without any collection cycle or deallocation or write barrier -- 
it reduces to a single pointer increment, which effectively 
has zero cost. Very hard to do better than zero cost allocations.

If the program is small and functional, there will be no cost
from write-barrier, and no collection cycle, not even
at the end (Ocaml doesn't collect on termination).

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net