NewRatio: to twiddle or not to twiddle
Charles Oliver Nutter
charles.nutter at sun.com
Tue Sep 2 13:06:05 PDT 2008
Moving the discussion here on Paul's recommendation.
Short version: JRuby achieves better performance using NewRatio=1. Paul
recommends also looking at MaxTenuringThreshold and SurvivorRatio.
There's a dearth of information on the interwebs about the best GC
settings (and HotSpot settings in general) for running object-intensive
dynamic languages like Ruby. Time to change that.
My original email:
> I've ben playing with JRuby on various benchmarks recently and found
> that several object-intensive scripts run better if I set NewRatio=1.
> Ruby, even more than Java, tends to generate lots and lots of objects,
> especially considering that there's no unboxed primitive numeric types
> (and no fixnums on the JVM...ahem ahem). So my general theory is that:
>
> 1. A NewRatio of 1 allows all those extra transient objects to get
> collected more quickly.
> 2. Too small a "new" generation causes transient objects to get shoved
> into older generations, potentially snowballing and forcing more
> comprehensive GC runs as time goes on.
>
> I'm curious whether this theory sounds reasonable, whether there's a
> better way I can adapt hotspot to the memory demands of a dynamic
> language like Ruby, and what other implications there are in setting
> NewRatio to 1.
>
> Thoughts?
>
> (And please let me know if there's a better list to post this sort of
> question to)
Paul Hohensee's response:
You probably want hotspot-gc-use at openjdk.java.net.
A NewRatio of 1 means that half the heap is young gen. The default
for the server vm is 2 (1/3 the heap is young gen) and for the client
vm it's 12 on x86 and 8 on sparc. I.e., much smaller young gen for
client.
1. A NewRatio of 1 doesn't allow transient objects to get collected more
quickly, it allows them time to die in the young gen and thus not get
collected at all. The bigger the young gen, the longer the interval
between collections, and the more time for transient objects to die.
2. Is correct.
You can increase the amount of time transient objects have to die by
increasing MaxTenuringThreshold. It can have values between 0 and 15,
and is the number of times an object must survive a young gen collection
before being promoted to the old gen. The survivor spaces in the young gen
must be large enough to contain everything that's live in the young gen,
else
the excess gets promoted before its time. So check out lower values of
SurvivorRatio as well: lower values increase the size of the survivor
spaces.
Paul
More information about the hotspot-gc-use
mailing list