|
Replies:
1
-
Last Post:
Aug 25, 2008 1:29 PM
by: paulby
|
|
|
|
|
|
|
Long loading time using big X3D files - solved
Posted:
Aug 25, 2008 4:30 AM
|
|
|
I have a big (10MB) X3D model file and it used to take over 20 minutes to load it into wonderland or j3dfly. I ran a profiler on the loading process to find out why it takes so long and traced the problem to the class com.sun.j3d.utils.geometry.GeometryInfo from the java3d-core-utils library.
It turned out that most of the time (over 90%) it takes to load a big X3D model is being spent in the method "getListIndices" which uses a HashMap to store instances of the private inner class GeometryInfo$IndexRow. Over 60% of the time was spent in hundreds of millions of calls to the equals method of IndexRow which meant that many instances of the class must have the same hash code. So I had a look at the hashCode method of that class and indeed, it returns 0 always!
When I replaced the original hashCode implementation with one of my own the loading time for the X3D model file went down from over 20 minutes to less than 2 minutes, most of which is spent in the xml library.
Here is the implementation of com.sun.j3d.utils.geometry.GeometryInfo$IndexRow.hashCode() that I used:
public int hashCode()
{
int bits = 7;
for (int i = 0 ; i < size ; i++) {
bits = (31*bits) ^ val[i];
}
return bits;
} // End of IndexRow.hashCode
Edit: I have also reported this in the Java3d issue tracker, https://java3d.dev.java.net/issues/show_bug.cgi?id=595
|
|
|
|
|
|
|
Re: Long loading time using big X3D files - solved
Posted:
Aug 25, 2008 1:29 PM
in response to: jsalonen
|
|
|
Good catch, thanks for the tracking down the fix. We've ported much of the GeometryInfo system to JME for 0.5, so I'll make sure this get applied to that code base as well.
Rgds
Paul
|
|
|
|
|