This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ReRe: performance (shellsort experiments)


Jeff Sturm wrote:

> That's more like it!  I wonder if this call could somehow be optimized
> away, if the compiler is smart enough to know that it is reassigning
> values from the same array... hmm... I wonder what happens if I replace
> "Object" with "Double" in the source and compile/run again:

> [Object sorting with    _Jv_CheckArrayStore():   59 seconds]
> [Object sorting without _Jv_CheckArrayStore():   17 seconds]
> [Double sorting (=specific type):                16 seconds]

Interesting! I have often wondered how much runtime overhead the
'generic type' approach to data structures in Java really implied.
I would never have guessed a factor of almost four, however.
Seems that C++-style templates are worth-while after all...

(Probably, most of us will already have  'production versions' of some
java.util classes with specific types and without all the 'synchronized' 
overhead.)


> That's it.  If we help the compiler a little it can optimize away the
> the call to _Jv_CheckArrayStore().

As the above result shows, having a smart compiler that detects 
this situation (reassigning an object to an array) might really help:
Object[] arrays are quite common idiom in Java, and many of the 
classes in java.util use such arrays interally, too.


- Norman


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]