jirr and irrlicht

Discussion about Irrlicht's Java wrapper
Post Reply
erol
Posts: 1
Joined: Thu Nov 30, 2006 6:42 pm

jirr and irrlicht

Post by erol »

Is there any performance difference between irrlicht with C++ and jirr? Is pass by value in java makes things much slower?
Andi|xng
Posts: 83
Joined: Thu Mar 24, 2005 10:49 pm
Location: Schrobenhausen, Germany
Contact:

Re: jirr and irrlicht

Post by Andi|xng »

No. I get nearly the same FPS rate with Jirr with the Techdemo for example.

But the communitaction is slow. If you need to pass much data to Irrlicht or back to Jirr, it can get very slow (e.g. never create new Irrlicht objects in each frame, try to reuse them as often as possible! Extend for example recti by a set(...)-method, so you can use it more often!), because the garbage collector seems to need extremly much time to clear up Irrlicht objects.
jirr
Posts: 36
Joined: Sat Feb 19, 2005 8:05 am

Post by jirr »

Andi is totally right - as usual ;)

Running jirr may reach the full c++ numbers (at least by 90 to 99,99% depending on your tasks) - but due to garbage collection this may decrease. Just think about a framerate of 1000 frames per second and intensive memory usage per frame. The gc will do a lot aof work ...

Also playing music (mp3) in pure java did reduce the frame rates. That's why there is also a java binding for irrklang in the latest version of jirr.

Last but not least with the upcoming jirr 1.3 there will be some overhead when it comes to textures being created in 100% java (not read from disk). Exchanging arrays between java and c++ is always more expensive than changing native ones. But do not expect it to be too slow to be used ;)
quintesse
Posts: 2
Joined: Thu May 03, 2007 9:11 pm

Post by quintesse »

The slowdown is most likely because of the finalizers like this one:

Code: Select all

  protected void finalize() {
    delete();
  }
The Java GC is notoriously slow for classes that use finalizers and even then it does not guarantee when those finalizers will be run... if ever!

Read this IBM article about Java finalizers: http://www-128.ibm.com/developerworks/j ... 0319a.html

(it has links to more interesting info about GC)

You might try to see what happens with the performance after you remove all the finalizers from the code. Yes I understand that this means that you should be very carefull to always delete your objects to prevent memory leaks but depending on the speed-gain it might be a price you are willing to pay.
quintesse
Posts: 2
Joined: Thu May 03, 2007 9:11 pm

Post by quintesse »

And about the passing of large amounts of data: that's what NIO buffers are for. Especially if all you are passing are things like vertices, indices and texture data you should consider switching to those buffers, the speed increase is considerable. The downside of course is that you won't be able to keep the API 100% similar to the C++ version.
Post Reply