Skip to main content

Terrible JDK 1.6 debugger performance

3 replies [Last post]
maartenc
Offline
Joined: 2004-07-14

Hi,

we recently switched from JDK 1.4 to JDK 1.6 and we noticed a dramatic debugger performance problem.

Consider the following code:

public static void main(String[] args) {
long start = System.currentTimeMillis();

for (int i = 0; i < 450000; i++) {
try {
throw new RuntimeException("test");
} catch (Exception e) {
}
}

long stop = System.currentTimeMillis();
System.out.println("Test took " + (stop - start) + "ms");
}

When I run this program with JDK 1.4, I have:
C:\test>java -version
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)
C:\test>java -Xdebug -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=n -cp . test.DebuggerTest
Test took 5700ms

With JDK 1.6 I have:
C:\test>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
C:\test>java -Xdebug -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=n -cp . test.DebuggerTest
Listening for transport dt_shmem at address: jdbconn
Test took 32671ms

As you can see, the code takes 5 seconds on JDK1.4 to finish, while on JDK1.6 it takes 32 seconds!!

Is there a way to configure the 1.6 JVM to have the same performance as in 1.4 ?

thanks,
Maarten

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
peter__lawrey
Offline
Joined: 2005-11-01

Exceptions are not the same as the debugger which is use to breakpoint code and look at variable etc.
Exceptions should be [b]exceptional[/b]. It is likely that the code has been optimised at the cost of building an exception.
Exception still takes less than 0.1 ms. If you want to optimise the use of exceptions then I suggest remove the errors from your code. How many errors per second should a program have? I suggest less than 1, not thousands.

maartenc
Offline
Joined: 2004-07-14

Peter,

I agree with you that exceptions should be exceptional. But we are not living in a perfect world and some APIs (including some of the Java APIs) don't have a proper API to avoid such an exception.

Isn't there a way to configure the JDK1.6 debugger to have the same performance settings as JDK1.4 (maybe a bit slower on "normal" code, but a lot faster on exceptions) ?

Maarten

peter__lawrey
Offline
Joined: 2005-11-01

I would say that thousands of exceptions per second is a less than perfect world. Perhaps its time to clean up the code so it can be maintained.
I don't know of any options to make exception go faster, I think it would be a sad day if they had to.
BTW, Exceptions have a significant performance hit without debugging too.