Help with performance issues.

Bill Bland
Mon Jul 30 02:12:00 GMT 2001

	We were having problems with the performance of our java
application under sun's jdk1.3 (using Mandrake linux 8 on an i686).  I
decided to try gcj to see if it would run faster.  I got the source for
gcc 3.0 and followed the installation instructions, and after a few tweeks
(took out some awt stuff) it compiled our application.

Unfortunately it now runs slower :-(

I looked at the faq for this, and at the thread "gcj performance on
Solaris 2.6" and I managed to get slightly better performance by giving
gcj a few flags, but it still runs about 10% slower than it did with

I'm compiling with:

gcj -static -O3 --no-bounds-checking -funroll-loops -finline-functions
-fkeep-inline-functions -march=i686 -malign-double --main=myprog -o myprog

I'm not sure if some of these flags are redundant (probably the compiler
already knows it's running on an i686 - just wanted to make sure it
doesn't compile for i386).

To give you an idea of what the bulk (in terms of cpu cycles) of our code
does, we have a class:

public class ourclass {
	ourclass next;
	ourclass tempnext;
	int id;
	int data[];
	int data_offset;
	int error;

The code spends most of it's time in various loops that look roughly like:

while( list != null ) {
  for( int i=list.data_offset;
       i < MAX && Math.abs([i]-input[i]) < ERR;
       i++ )
  if( i==MAX )
    return list;
  list = list.tempnext;

So most of the code is tracing lists and accessing array elements.
The thing that makes the code slow is that we typically have lists of
length around 320,000 elements and the arrays are typically around 1000
elements long.  This is unavoidable.
I can't think of anything obvious (e.g. allocating and de-allocating lots
of small objects) that would be causing our code to run slowly when
compiled with gcj, but it still does!

I'd be very greatful for any suggestions anyone might have.
Thanks in advance,
		William Bland.

More information about the Java mailing list