JNI & 64-bit windows = slow?

Discussion in 'Java' started by Christopher Yeung, Nov 24, 2007.

  1. Help... I don't know why JDK would introduce such an overhead:

    I've a Win 64-bit C++ routine that uses dynamic cast/RTTI heavily. I'm
    aware of the fact that pure C++ code that uses RTTI/dynamic cast runs
    slower in native 64-bit Windows than WOW. But when I put the same
    routine inside a 64-bit JVM, the performance degraded by 300%. Can
    somebody explain why the difference? AFAIA the JVM shouldn't introduce
    so much overhead.

    If the C++ routine is compiled as win32 library and run on WOW, the
    benchmark is about 1 sec.
    If the same C++ routine is compiled as a win64 library and run as native
    64-bit, the benchmark is about 1.4 sec.
    If the same win64 compiled library is run inside a 64-bit JDK1.5.0_10,
    the benchmark is about >4.2sec. <==== 300% performance degradation!!!

    All the timings were collected on the same 64-bit Windows 2003 Server box.

    Many thanks in advance.

    Chris
     
    Christopher Yeung, Nov 24, 2007
    #1
    1. Advertising

  2. More results from testing:

    The performance degradation seems to be specific to 64-bit Windows.
    There is no statistically significant difference between running the
    routine in native C++ or inside a JVM on SPARC machines. In fact there
    is no significant difference on 32-bit Windows either.
    Just why a 64-bit compiled library uses dynamic casts and running inside
    a 64-bit JVM on Windows would incur such an overhead??


    Christopher Yeung wrote:
    > Help... I don't know why JDK would introduce such an overhead:
    >
    > I've a Win 64-bit C++ routine that uses dynamic cast/RTTI heavily. I'm
    > aware of the fact that pure C++ code that uses RTTI/dynamic cast runs
    > slower in native 64-bit Windows than WOW. But when I put the same
    > routine inside a 64-bit JVM, the performance degraded by 300%. Can
    > somebody explain why the difference? AFAIA the JVM shouldn't introduce
    > so much overhead.
    >
    > If the C++ routine is compiled as win32 library and run on WOW, the
    > benchmark is about 1 sec.
    > If the same C++ routine is compiled as a win64 library and run as native
    > 64-bit, the benchmark is about 1.4 sec.
    > If the same win64 compiled library is run inside a 64-bit JDK1.5.0_10,
    > the benchmark is about >4.2sec. <==== 300% performance degradation!!!
    >
    > All the timings were collected on the same 64-bit Windows 2003 Server box.
    >
    > Many thanks in advance.
    >
    > Chris
     
    Christopher Yeung, Nov 24, 2007
    #2
    1. Advertising

  3. Christopher Yeung

    Roedy Green Guest

    On Sat, 24 Nov 2007 22:55:34 GMT, Christopher Yeung
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Help... I don't know why JDK would introduce such an overhead:


    I suspect the problem is in 64-bit windows. It may still contain large
    hunks of 32-bit code. When your 64-bit C calls OS services there is
    an overhead to flip to 32 bit code and back.
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Nov 25, 2007
    #3
  4. Christopher Yeung

    Roedy Green Guest

    On Sun, 25 Nov 2007 03:43:11 GMT, Roedy Green
    <> wrote, quoted or indirectly quoted
    someone who said :

    >I suspect the problem is in 64-bit windows. It may still contain large
    >hunks of 32-bit code. When your 64-bit C calls OS services there is
    >an overhead to flip to 32 bit code and back.


    You can check if I am correct by writing some standalone C code for 32
    bit and 64 bit Windows and benchmarking it.
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Nov 25, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    869
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    936
    Pasturel Jean-Louis
    Mar 3, 2004
  3. Replies:
    3
    Views:
    1,829
    Timothy Bendfelt
    Jan 19, 2007
  4. Replies:
    9
    Views:
    1,031
    Juha Nieminen
    Aug 22, 2007
  5. Jeff.M
    Replies:
    6
    Views:
    198
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page