Title: improving performance in access to multidimensional array elements
Well, I don't pretend that I have *the* answer, but I think that in the second test you pass a treshold where the hot spot compiler jumps in. If it sees that a certain computation takes exceedingly long time, that's a *hot spot* and it is natively compiled. At that point, the native multiplication of two integers it is really fast, so it doesn't matter so much if you compute the index into a 2x array or 1x array.
 
Regarding the 4 x 4 matrix used by j3d to operate on transforms, if I have an ideal 100 fps with 50 matrixes to copy, the performance gain with the new copy in 1 sec will be 9,14 ms. Not really detectable by the human senses.
 
Florin
-----Ursprüngliche Nachricht-----
Von: Nathan Bower [mailto:[EMAIL PROTECTED]]
Gesendet: Dienstag, 28. Januar 2003 13:25
An: [EMAIL PROTECTED]
Betreff: Re: [JAVA3D] improving performance in access to multidimensional array element s

Hi Alan,
 
Great program! I have a question for you - I use 2D arrays of integers in my program either of 400x400 cells or 800x800 cells, and operate on the values (perhaps 5-10 accesses to each value) individually. I compiled your program and ran it with what I think are sensible values to test the perfomance gain with this array geometry.
 
javac MatrixCopyTest.java
 
java MatrixCopyTest 400 400 5
ebe 261
row 150
improvement 42.52873563218391 %
ebe takes 74.0 % longer
 
java MatrixCopyTest 400 400 500
ebe 19638
row 17976
improvement 8.463183623586923 %
ebe takes 9.2456608811749 % longer
 
Can you help to explain why the method you describe is slower in this test case?
 
Regards,
 
N
 
----- Original Message -----
Sent: Monday, January 27, 2003 7:04 PM
Subject: [JAVA3D] improving performance in access to multidimensional array element s

This is a performance issue concerning any matrix-esque object backed by a multidimensional array. I know it relates to GMatrix, but could include others. (GMatrix is the only one I've decompiled to look at.)

While pawing through GMatrix, I noticed that systematic element access is performed in an element-by-element manner. However, when accessing the elements of a multi dimensional array, making use of the row major implementation to grab the row array first, and then accessing elements in the row may improve performance. This way, you only index into single dimension arrays, which is faster.

The attached file demonstrates the improved performance in a matrix copy operation. Here is a sample of the results. Improvement varies with matrix geometry. Parameters are #rows, #columns, #copies. Values printed are millisecs.

C:\ >java MatrixCopyTest 4 4 3000000

ebe 5484

row 1266

improvement 76.91466083150985 %

ebe takes 333.17535545023696 % longer

C:\ >java MatrixCopyTest 100 20 500000

ebe 29250

row 14718

improvement 49.68205128205128 %

ebe takes 98.7362413371382 % longer

C:\ >java MatrixCopyTest 20 100 500000

ebe 18844

row 14391

improvement 23.630863935470177 %

ebe takes 30.942950455145578 % longer

I hope this isn't a well known/well trod issue. I searched the message history and saw no discussion of it.

Alan

<<MatrixCopyTest.java>>

Reply via email to