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]

Re: performance problems


Can you narrow down the performance problem?  Profiling seems to work
for gcj executables (I've used it successfully).  There probably are
some undetected bottlenecks somewhere in the libgcj code.  Perhaps
libgcj should be recompiled with profiling enabled.

Also, try running vmstat during your benchmark to look for unusual
system activity, like high page faults or excessive context switches.

My benchmark program, a small web server written in java, runs about 30%
faster with gcj than it does with the IBM JDK.  That was with 2.95
prerelease code.  (It handles about 450 HTTP requests/sec, not too bad
for *any* web server.)  I ran the tests partly to stress-test the thread
and synchronization primitives in libgcj.

One thing I discovered that could affect others testing libgcj
performance is that synchronized blocks in libgcj rely on pthread
mutexes, which (at least on Linux) spin forever in a yield loop; they
never go to sleep before they grab the lock.  So long-term synchronized
blocks should be avoided in favor of higher-level mechanisms based on
wait/notify.  (Anyone know what the JDK does?)

I also found that the spinlock algorithm in LinuxThreads works poorly on
multiprocessors.  It tries to yield on each loop iteration, which has no
effect when there are idle processors.  I was able to improve java
performance considerably on a 4-way Linux SMP just by tuning the
hardcoded spinlock parameters.  Context switches from over 1000/second
to under 100.  I should probably mention this to the LinuxThread
maintainer, whoever that is...


Norman Hendrich wrote:
> what are the experiences with the performance of gcj compiled apps?
> 
> On by Linux box at home, gcj compiled apps run about 5 times _slower_
> than under IBM JDK 1.1.6 (which in turn is slower than the current
> M$VM and SUN Hotspot under Windows on the same box).
> 
> What did I do wrong? I went to the adventure of building gcj/libgcj
> mainly to get better performance for our MIPS simulator...

--
Jeff Sturm
jsturm@sigma6.com

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