Expressive programming language? Was: [Gllug] Speaker Suggestion

Doug Winter doug at pigeonhold.com
Fri Jan 9 11:07:32 UTC 2004


On Thu 08 Jan Richard Jones wrote:
> As in not just reference counting.  If you're reference counting,
> you're suffering a time and space overhead on many common operations.
> Java (for all its sins), ML, Lisp, Haskell, etc. include garbage
> collectors which don't suffer such problems, and are consequently more
> efficient - more efficient even than allocating everything by hand.

It seems efficiency is subjective in that case :)

Theoretically optimal garbage collecting is hugely overrated.  I've had
vast amounts of grief with Java's supposedly wonderful GC - it's got a
whole range of algorithms, all of which suck at some workloads.

We run Weblogic, and we can't afford to have the whole thing hang like
an idiot for 30 seconds while it GCs, because requests will go
unanswered.  So we've ended up running the full monty: the train
incremental generational mark/sweep copying collector algorithm.

This uses bucketloads of memory (approximately twice what it needs - and
being java it needs more memory than you can ever afford) underperforms
on typical VM systems (can you say 'paging'?), is almost impossible to
optimise for because the cost is spread and it can be very *very* late
in cleaning some things.  This means you can't use it to collect scarce
resources like file handles.  Or indeed, memory, which is now really
scarce because you are running Java.

Reference counting on the other hand collects early (aside from cycles)
so you can use it to clean up scarce things, is deterministic and simple
and *works*.  Then it's got the mark/sweep cycle detector in the
background, to deal with the corner cases.  

The only remaining problem is cycles that contain more than one
finalizer - you have to handle those yourself, but there's an API.  And
you very rarely get them, and you should damn well know when you're
making one.

Here's a quote by Ken Thompson talking about Plan 9, where they do the
same thing:

http://www.computer.org/computer/thompson.htm
> ...Sean decided the whole system had to have a garbage-collected
> language at a much higher level in that it's not separate interacting
> processes maintaining their own addresses, with some being
> garbage-collected and some not.
> 
> The language and the system are all garbage-collected together.
> Whatever protection mechanisms you have for the language apply all the
> way down through the system. For example, if you open a file, you
> don't have to close it. If you stop using it, just return from the
> function and it will be garbage-collected and the file will be closed.
> So the system and the language are part of the same ball of wax.
> 
> In addition, the language implementation - and again I don't want to
> take any credit - doesn't have big mark-and-sweep type garbage
> collection. It has reference counting: If you open something and then
> return, it's gone by reference count. Thus, you don't have high and
> low watermarks because 99 percent of the garbage goes away as soon as
> it is dereferenced. If you store a null in a pointer, it chases the
> pointer and all that stuff goes.
> 
> If you make cycles, there is a background distributed mark-and-sweep
> algorithm that just colors the next step a little bit at a time. It
> doesn't have to be very aggressive because there is not much garbage
> around in most applications: People really don't leave dangling loop
> structures that require this kind of algorithm. So you can devote just
> one percent of your time in the background looking for garbage without
> these monster mark-and-sweep things.
> 
> So, again, it's pragmatic. It's not the theoretical top-of-the-line
> garbage collection paper. It's just a way of doing it that seems to be
> very, very effective.
 
I vote for simple GC every time.  The Java guys can go back to writing
papers for each other - which they must do far better than writing
operational software.

</rant>

doug.

-- 
6973E2CF print 2C95 66AD 1596 37D2 41FC  609F 76C0 A4EC 6973 E2CF
"Like a tramp in the night, I was begging for you"
    -- Samantha Fox

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list