JDT Debugger Big Slowdown [message #331614] |
Sun, 14 September 2008 00:39  |
Eclipse User |
|
|
|
I have java code that takes 6 seconds to run in Eclipse normally and 200
to run in the debugger. The code calls a JRE method a million times and
that method internally throws and catches an exception.
I reproduced this with a quick junit test (code below). When I click
run in Eclipse it takes 3.877 seconds. When I click debug it takes
144.452 seconds.
I am not surprised there is a slowdown, but this is huge! Is this an
overhead caused by JDI, or is it due to the Eclipse debugger? Any ideas
to workaround it? e.g. turn off some feature?
Thanks,
Will
import org.junit.Test;
public class ExceptionDebugTest {
@Test
public void run() {
for (long i = 0; i < 1000000L; i++) {
try {
throw new Exception();
}
catch (Exception e) {
}
}
}
}
|
|
|
|
|
|
|
Re: JDT Debugger Big Slowdown [message #331663 is a reply to message #331661] |
Mon, 15 September 2008 21:17  |
Eclipse User |
|
|
|
David Wegener wrote:
> Will Horn wrote:
>> The same behavior happens in IntelliJ, so I guess this is not caused
>> by JDT.
>>
>> Will Horn wrote:
>>> Thanks for the response. Actually I am running in the debugger with
>>> no breakpoints at all. I even tried unchecking everything in the
>>> Java\Debug preference page and still there is the same 30x slowdown.
>>>
>>> Francis Upton (News) wrote:
>>>> Make sure you don't have any conditional breakpoints. They can
>>>> cause lots of overhead. Clear all of your breakpoints if there is
>>>> any doubt. Normally running with debug and no breakpoints is pretty
>>>> much as fast as the real thing.
>>>>
>>>> Will Horn wrote:
>>>>> I have java code that takes 6 seconds to run in Eclipse normally
>>>>> and 200 to run in the debugger. The code calls a JRE method a
>>>>> million times and that method internally throws and catches an
>>>>> exception.
>>>>>
>>>>> I reproduced this with a quick junit test (code below). When I
>>>>> click run in Eclipse it takes 3.877 seconds. When I click debug it
>>>>> takes 144.452 seconds.
>>>>>
>>>>> I am not surprised there is a slowdown, but this is huge! Is this
>>>>> an overhead caused by JDI, or is it due to the Eclipse debugger?
>>>>> Any ideas to workaround it? e.g. turn off some feature?
>>>>>
>>>>> Thanks,
>>>>> Will
>>>>>
>>>>> import org.junit.Test;
>>>>>
>>>>> public class ExceptionDebugTest {
>>>>>
>>>>> @Test
>>>>> public void run() {
>>>>> for (long i = 0; i < 1000000L; i++) {
>>>>> try {
>>>>> throw new Exception();
>>>>> }
>>>>> catch (Exception e) {
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>
>>>>
> My guess is that when you aren't running in debug mode, the jit compiler
> is kicking in and optimizing out most of your code since it doesn't
> actually do anything. When running in debug mode, the jit compiler
> isn't kicking in.
>
> Jit side effects are something you have to keep in mind when attempting
> to write benchmark code such as this.
>
> See if the following behaves differently:
> public void run() {
> int exceptionCount = 0;
> for (long i = 0; i < 1000000L; i++) {
> try {
> throw new Exception();
> }
> catch (Exception e) {
> exceptionCount++;
> }
> }
> System.out.println("Caught " + exceptionCount + " exceptions.");
> }
Thanks for the idea, and good point about the JIT compiler. But I
tested your code and still see the same behavior. Even just running
java -agentlib:jdwp=transport=dt_shmem,server=y,suspend=n Foo
has the slowdown.
|
|
|
Powered by
FUDForum. Page generated in 0.03677 seconds