Thanks for your answers!
Quote:
mm, interesting.
How much difference in performance?
Frankly I can´t tell, but I don´t like to have an allocation hell going on in my project. Maybe its not a big deal in this example, but it has a potential to sum up quickly. The JMonkeyEngine guys seem to be fine - maybe I should be too...but I don´t like to run allocations out of control.
Quote:
Java, due to the design of its memory model, is worst possible case for this type of operations and will always remain as such. The biggest problems do not come from temporaries, but from lack of in-place array allocations.
Actually that is not quite right... I use ByteBuffer objects to store all my vertices (same for matrices) and pass them to the jni c++ layer. ;-)
But you are right. This is an annoying hack... but I got around with that.
So no big performance hit here...
I primarily chose java because I hoped for more productivity. That has been mostly right up to now, because of the great refactoring tool support, lack of header files and so on. I was also annoyed of all the small flaws of c++ one has to work around... its simply not a clean language.
It would be a strange insight in my programming career that c++ might actually allow MORE intuitive programming concerning algebra than java.
Frankly I like java and its dynamic nature... There are just a few flaws. EA could solve the stack allocation problem.
Quote:
Escape analysis under 1.6 has been shown to provide around factor of 15 performance improvement in best case
How the heck do I reliably switch that thing on (Yes I tried the -XX:+UseEscapeAnalysis flag). If I am right it is as equally capable than the C++ stack scope auto-deallocation thing, plus may be more capable in future.
The analysis phase takes startup time, but that doesn´t matter.
I have come to believe that EA never worked in any example (That one I wrote about, was most likely a change of scala in the profiler, which seemed like
lower allocation level).
Has anybody perceived real results with EA and can tell me a method to reproduce that, how to enable and verify that it kicks in ?
Lets take this example again:
Quote:
public void rotate(float angle, Vector3 axis) {
Matrix3 rotationMatrix = new Matrix3();
rotationMatrix.loadAxisAngleRotation(angle, axis);
rotationMatrix.transformOnlyOrientation(this);
}
The matrix allocation should be clearly optimized, or am I wrong about that ?
Quote:
But that implies that the escape analysis has to be performed through n-level indirection. I am not sure about that. I cannot deduct that from the link. Can you give me any hint?
Ok you refer to my first more complicated example, keep in mind, that the simpler also does not work for me. But... I have no exact source, but I figured if that HotSpot is capable of:
Quote:
The method makes a copy to prevent modification of the original object by the caller. If the compiler determines that the getPerson() method is being invoked in a loop, it will inline that method. In addition to this, by escape analysis, if the compiler determines that the original object is never modified, it may optimize and eliminate the call to make a copy.
Lets see:
1.)multiply is in a loop and gets inlined.
2.)transform() is in multiply and thus in a loop (the indirection you mentioned)
3.)dx is read only accessed and its pointer is not stored in a collection
So the case is at least similar... why would hotspot only inline one call level.
Why wouldn´t it bake the second level also into one big soup !? ,-)
Not sure about that, but keep in mind, that the more obvious example I provided before doesn´t work either.
Quote:
Java, due to the design of its memory model, is worst possible case for this type of operations and will always remain as such.
Quote:
Until Java introduces C# struct-like type, it's simply not economically viable for this type of tasks.
Don´t be so hard to java. Its actually a good language and HotSpot is magic. Also run-time code loading and reflection gonna be cool in gamedev. Netbeans
is also superior to VS. You don´t believe ? It is... I know both ;-)
There are some pieces missing. But... if an "array"-pool allocation mechanism gets added to OpenJDK and EA does work reliably the language would be there.
I am too busy with game development (-:, but some compiler freaks could kick it...
Till then use ByteBuffers and wrapper classes to solve the pool problem.
C# is not so cross platform and I simply won´t learn another system.
I like java and I don´t feel like going to c++, at least not yet. Please help
me to get that damn thing going !!!
Thank you for your kind attention,
Frederik