A smaller GC benchmark

Robert Fraser fraserofthenight at gmail.com
Mon Dec 10 12:48:00 PST 2007


bearophile wrote:
> This tiny benchmark focus on GC performance and shows similar results to the "binary trees" benchmark I have shown here few weeks ago, but it's quite shorter, so it may be more useful. This code isn't meant to represent normal programs with thousands of classes, etc, it just shows something quite limited. This is an adaptation of the "Object Test" that you can find used and discussed here:
> http://www.twistedmatrix.com/users/glyph/rant/python-vs-java.html
> http://blog.snaplogic.org/?p=55
> http://programming.reddit.com/info/24ynh/comments
> Note that I test the GC of Phobos only, I don't use Tango yet.
> 
> 
> Object Test timings (on PIII @ 500 MHz), best of 3 runs (seconds, approximate Mbytes memory used), n=1_000, m=10_000:
>                seconds  MB
>   DMD class:   18.95    1.7
>   GDC class:   17.91    1.8
>   DMD struct:  11.77    1.7
>   GDC struct:  12.31    1.8
>   Python:      37.10    3.1  (ShedSkin version)
>   Psyco:       15.68    3.5
>   ShedSkin      6.35    1.6
>   Java (1):     2.19    7.3
>   Java (2):     2.10    7.8
> 
> See below for the sources. You can see the Java is about 9 (~= 18.95 / 2.10) times faster than the program produced by DMD. Even Psyco (the JIT for the turtle-slow language Python) gives faster performance (and the Python GC is simple, it's just a reference count plus cycle detection). You can also see Java (as usual) uses much more RAM (7.8/1.7 ~= 4.6).
> 
> Note that with some manual GC optimization the running time for the DMD class benchmark can become about one-two seconds smaller, but the memory used can be about 4 MB:

I've been wanting for a while to implement a different GC for D taking 
into account some of the stuff talked about in a few papers I read on 
non-moving GCs. IMO, D's GCs (Tango & Phobos) are pretty basic, they 
don't do any sort of sexy trickery.

FWIW, I don't think non-moving GCs will ever be able to outperform a 
well-tuned generational collector. But I'm not exactly in the know about 
these things, so I may be wrong.



More information about the Digitalmars-d mailing list