DaCapo benchmarks
Andrew Haley
aph@redhat.com
Mon Nov 7 15:53:00 GMT 2005
I found out why gcj is so slow on ps, and it seems to be that
ps is throwing millions of exceptions. It boils down to this method:
/**
* Returns the value associated with the key term.
* @param key Key term.
* @return PSObject No such value -> null, else -> associated value.
*/
public PSObject getValueOf( PSObject key ) throws PSObjectException
{
/* attempting to get value from an empty dictionary */
if( ((ArrayList)value).isEmpty() )
{
throw new PSObjectException( "empty dictionary" );
}
/* Iterates through the arraylist, searching for the pair with the
given key term. */
PSObject returnObject = null;
for( int i = 0; i < ((ArrayList)value).size(); ++i )
{
if( ((Pair)((ArrayList)value).get( i )).isKey( key ) )
{
returnObject = ((Pair)((ArrayList)value).get( i )).getValue();
break;
}
}
/* Can't find the key at all. */
if( returnObject == null )
{
throw new PSObjectException( "can't find key" );
}
return returnObject;
}
If you look at its spec, getValueOf() is supposed to return null if a
value is not found. However, it does not do that: it throws an
exception instead.
The gcc exception processing mechanism is designed to be very fast for
the "never thrown" case, but it is slower when exceptions are thrown.
I suppose gcj could change to optimize for things like this, but IMO
it would not be such a good idea for "reasonable" applications.
I'm very tempted to fix getValueOf() so that it does what its
specification requires, but that would invalidate the benchmark.
Andrew.
More information about the Java
mailing list