I'm using jdi interfaces to create a debugger and when I use MethodEntryRequests to enable method entry tracing the debugged program slows down by factor of tens. I have set filter for main thread and suspend policy to SUSPEND_EVENT_THREAD. Classfilter is limited and if I print any received events it doesn't show more than couple of dozen of those so it shouldn't receive too much of them. I'm debugging locally and having followind kind of command-line with the debugged java program:
我正在使用jdi接口来创建调试器,当我使用MethodEntryRequests来启用方法条目跟踪时,调试程序的速度减慢了几十倍。我为主线程设置了过滤器,并将策略暂停到SUSPEND_EVENT_THREAD。 Classfilter是有限的,如果我打印任何收到的事件,它不会显示超过几十个,所以它不应该收到太多。我正在本地调试并使用调试的java程序跟随它的命令行:
-Xdebug -Xrunjdwp:transport=dt_socket,suspend=y,server=y,address=1337
3 个解决方案
#1
31
The short answer is that execution runs through the interpreter when method entries are set. I don't think there is anyway around this...
简短的回答是,在设置方法条目时,执行会通过解释器运行。我不认为这周围有...
This used to be the case for all code running in debug mode but it was enhanced in 1.4... now HotSpot works for 'full-speed' debugging except in the case of method entries and exits, watchpoints and when single stepping or in methods that contain breakpoints.
这曾经是在调试模式下运行的所有代码的情况,但它在1.4中得到了增强...现在HotSpot可用于“全速”调试,除了方法入口和退出,观察点以及单步执行或方法时包含断点。
#2
11
2 reasons:
- it has to add checks on every method entry (there is no option to tweak just some methods)
- method inlining becomes impossible (so small methods runs 10-100x times slower)
它必须在每个方法条目上添加检查(没有选项可以调整一些方法)
方法内联变得不可能(因此小方法运行速度慢10-100倍)
same goes to profilers and .net apps
同样适用于分析器和.net应用程序
#3
5
I would assume that the debugger needs to wake up for every method call to see if it matches the one(s) that were selected to break. Because it has to check every method call for a potential match before it can execute it is considerably slower than if it does not have to do all these checks.
我假设调试器需要为每个方法调用唤醒,以查看它是否与选择要中断的方法匹配。因为它必须在可执行之前检查每个方法调用潜在匹配,所以它比不必执行所有这些检查要慢得多。
#1
31
The short answer is that execution runs through the interpreter when method entries are set. I don't think there is anyway around this...
简短的回答是,在设置方法条目时,执行会通过解释器运行。我不认为这周围有...
This used to be the case for all code running in debug mode but it was enhanced in 1.4... now HotSpot works for 'full-speed' debugging except in the case of method entries and exits, watchpoints and when single stepping or in methods that contain breakpoints.
这曾经是在调试模式下运行的所有代码的情况,但它在1.4中得到了增强...现在HotSpot可用于“全速”调试,除了方法入口和退出,观察点以及单步执行或方法时包含断点。
#2
11
2 reasons:
- it has to add checks on every method entry (there is no option to tweak just some methods)
- method inlining becomes impossible (so small methods runs 10-100x times slower)
它必须在每个方法条目上添加检查(没有选项可以调整一些方法)
方法内联变得不可能(因此小方法运行速度慢10-100倍)
same goes to profilers and .net apps
同样适用于分析器和.net应用程序
#3
5
I would assume that the debugger needs to wake up for every method call to see if it matches the one(s) that were selected to break. Because it has to check every method call for a potential match before it can execute it is considerably slower than if it does not have to do all these checks.
我假设调试器需要为每个方法调用唤醒,以查看它是否与选择要中断的方法匹配。因为它必须在可执行之前检查每个方法调用潜在匹配,所以它比不必执行所有这些检查要慢得多。