This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: DaCapo benchmarks
- From: Andrew Haley <aph at redhat dot com>
- To: java at gcc dot gnu dot org
- Date: Mon, 7 Nov 2005 15:55:59 +0000
- Subject: Re: DaCapo benchmarks
- References: <63006.202.55.156.222.1128986731.squirrel@sqmail.anu.edu.au><1129493766.5880.59.camel@localhost.localdomain><47717.66.181.12.81.1129565596.squirrel@sqmail.anu.edu.au><1129976855.4617.26.camel@localhost>
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.