Howto: Profiling GCJ code?

Patrick Schäfer
Mon Jun 22 19:25:00 GMT 2009

thank you for the help!

oprofiler is quite troublesome to build on my mac os x as there a lots  
of libraries missing. currently "bfd" (-lbfd) is missing.

therefor I am still not sure if java.nio is the main reason for the  
performance bottleneck but apache mina is also capable of using APR as  
a transport layer (instead of java.nio).  that could improve overall  
performance too.


Am 22.06.2009 um 15:35 schrieb Ian Rogers:

> Hi,
> I just wanted to add a note that to improve the nio performance for
> the DaCapo benchmark suite certain special cases were optimized in
> Jikes RVM's usage of VMChannel from Classpath (LGPL source visible at
> [1]). The FileSystem object within JikesRVM just provides a means to
> access open/close/read/write calls without the overhead of JNI (in
> much the same way as CNI does for GCJ). There exists CNI channel code,
> if nio is a performance problem I believe something can be learnt from
> the RVM code base as I don't believe NIO is a performance issue in the
> RVM any more.
> Regards,
> Ian
> [1];a=blob;f=libraryInterface/GNUClasspath/LGPL/src/gnu/java/nio/;h=8edf32bbf1d630c34b8db317c25376ba85e2a930;hb=HEAD
> --
> Metacircular Research Platform ( ), supports
> the development of optimized metacircular Virtual Machines in Java on
> Linux, OS/X and Windows.
> 2009/6/19 Bryce McKinlay <>:
>> The tool of choice for libgcj profiling is oprofile:
>> This should give you reasonably accurate, low-overhead profiling
>> without having to recompile anything, and even a call graph though
>> both the java and C/C++ code.
>> It doesn't surprise me that libgcj's java.nio is slow. Hotspot VMs  
>> can
>> also optimize nio code in ways that gcj can't.
>> Bryce
>> On Fri, Jun 19, 2009 at 9:52 AM, Patrick Schäfer<> wrote:
>>> Hi,
>>> I am trying to run a server based on apache mina (java.nio) and  
>>> jna for
>>> native library access. The program runs just fine under jdk 1.5.  
>>> But there
>>> is a massive performance breakdown using gcj. The program  
>>> basically polls a
>>> Posix Message Queue every 500ms using JNA (JNI). This causes 5%  
>>> cpu load on
>>> jdk but the load goes up to 100% using gcj.
>>> Is there any profiling tool which can be easily installed and  
>>> applied to the
>>> native code?
>>> I read about profiling gcj applications on your faq. There are 3  
>>> tools
>>> mentioned. To my understanding gprof can't be applied due to missing
>>> multithreading support and it requires the program to exit main  
>>> before
>>> writing any profiling information. The later is not easy when  
>>> using a
>>> network server. cprof seems to be quite outdated (there has been  
>>> no realease
>>> within the last years) and trying to "make" it, fails with several  
>>> errors. I
>>> don't know about sprof, but I couldn't find much information about  
>>> it on the
>>> internet.
>>> Thank you for any hints about current multithreading gcj (gcc)  
>>> profilers
>>> Patrick

More information about the Java mailing list