Performance Comparisons

Oh, yes I do that all the time as a matter of sheer habit if you’re referring to keeping Xms and Xmx to be the same and equal to 300MB, for instance. If you look at some of my earlier e-mails under “GC Implementation Specifics” and “Problem with OutOfMemoryError” under this tuning topic, you will notice that that’s what I do. I picked up this hint, to be honest, from the Sun Performance Tuning “white paper”.

Just to keep the record straight, I’ve been fairly vocal in claiming that Java’s polymorphic method call and number crunching performances have been quite good and, if I may guardedly say so, even better than C++ in some cases with the server option.

In principle, my application should be able to handle gigabytes of data, even if not taxed typically in one shot, but certainly when run in a transient mode with hundreds of streaming datasets all within a max heap of 300-500MB or so. Each time a new dataset comes in, a dataflow network in conjunction with Java3D’s scenegraph structure, updates itself automatically and allocates and deallocates memory for humble things like texture mapping to more exotic things like dynamically phong shaded haloed lines, texture advection, animation, and convolution etc.

Some of my microbenchmarks for stressing gc indeed show that the gc munches garbage as if it were the last sweetest thing on earth :).

Let me know if you or folks here run into any extra-ordinary gc pauses.

I think escape analysis would definitely be a boon; a 20% performance increase from their use would be fantastic for applications where GC starts to cause trouble. There are some more unusual uses for Java where the increased predictability of garbage generation and collection are very worthwhile goals too - realtime TV graphics, an area in which I work, is a constant battle against allocation. It’s not actually the collection that’s the problem as such, it’s just that it invariably occurs when you get a new() in the middle of a frame render… and it only takes 1 dropped frame for the production team to scowl nastily and make noises about using C instead. So I have to go through my code with an ultrafine toothcomb all day long optimising perfectly decent bits of OO and replacing them with ugly bits. Consider:


for (Iterator i = graphics.iterator(); i.hasNext(); ) { ((Renderable) i.next()).render(); }

Once that’s been through the inliner and code profiler there is no reason for it to put anything on the heap at all. Unfortunately it might just happen that it’s the straw that breaks the camel’s back and it triggers a teeny little collection just at the wrong moment…

Cas :slight_smile:

I happily concede that real time tasks could benefit from escape analysis. In general programming a more important benefit may be psychological — it would encourage people to use Iterators and not indulge in some much premature optimisation.

Exactly. And all those stupid, stupid, unsafe private static final Vector3fs I keep hanging around in Alien classes to do collision detection stuff would be history as well. No GC on Earth can keep up with 5,000 new Vector3fs every frame without glitching frequently but escape analysis would solve the problem instantly without compromising the code paradigms. Or somesuch.

Cas :slight_smile:

You know…I couldn’t have phrased it any better :).

I try not to comment on gc issues here because somehow I got the general impression that smart gamers pre-allocate objects and gc is a non-issue. But I also feel that if at all there is some group that can legitimately take performance issues to Sun, then surely no group more well poised and qualified than this !

On a very philosophical level I keep debating to myself if sometimes predictability of performance is more important than performance itself…

Predicability is nearly always more useful.

Cas :slight_smile:

If I understand the whole concept correctly, escape analysis would also mean that many programs will allocate less memory, am I right?
Another question, if lots of temporary objects are deleted ‘instantly’, would that not have a negative impact on creation of those objects? I’m thinking that ‘eden’ stuff and such.

Eden still has its place. Escape analysis is performed after inlining and can only be performed on small windows of code. Eden will trap those objects that fall outside the window, but which still are only very short lived. However, escape analysis will likely substantially reduce the number of objects being created in eden in the first place. The real guys to ask are Excelsior, as they’ve had it for quite some time in Jet and there’s no denying Jet performance blows the current VM away in several areas.

Cas :slight_smile:

[quote]I try not to comment on gc issues here because somehow I got the general impression that smart gamers pre-allocate objects and gc is a non-issue.
[/quote]
I for one am fed up of writing methods that take 6+ float and int args when really what they should be taking is (say) a couple of Vector2f’s and a Colour4f object. Yet I’m ever so slightly paranoid that making these objects every frame for processing then chucking them away is going to make the GC eat my performance.

I suppose its only a minor gripe, but just occasionally when I get a bug because I stuck the parameters in slightly wrong is a bug I could of avoided. :-[

That’s a notorious bug which is oblivious to age, experience, and expertise :-). 11.00PM-3.00AM is a good time to troubleshoot those.