简体   繁体   English

当连接到具有许多线程的远程JVM时(即通过TCPIP传输线程调试信息),Java的JDB(和Eclipse)会挂起

[英]Java's JDB (and Eclipse) hang when connecting to remote JVMs with many threads (i.e. transmitting thread debug information via TCPIP)

Problem Description 问题描述

Hi everyone, 嗨,大家好,

I was having problems remote debugging to a new server today and it initially appeared as if Eclipse was taking a long time to connect to a remote JVM. 我今天远程调试到新服务器时遇到问题,最初看起来好像Eclipse需要很长时间才能连接到远程JVM。 However, after some investigation I realized jdb was having a similar problem. 然而,经过一番调查后,我意识到jdb遇到了类似的问题。 Some digging turned up this... 一些挖掘出现了......

Connecting to the remote JVM is not a problem. 连接到远程JVM不是问题。 Both debuggers establish the socket connection properly within a few seconds. 两个调试器都会在几秒钟内正确建立套接字连接。 jdb even processes commands. jdb甚至处理命令。 However, after a remote debugger has connected to it successfully, the Sun Java 1.7.0_60-b19 JVM appears to be hanging (or transmitting extremely slowly) when sending its thread debugging information (JVMTI/JDWP) across the network via TCPIP. 但是,在远程调试器成功连接到它之后,当通过TCPIP在网络上发送其线程调试信息(JVMTI / JDWP)时, Sun Java 1.7.0_60-b19 JVM似乎挂起(或传输速度非常慢)。

Listing the remote JVM's threads appears to be the problem. 列出远程JVM的线程似乎是个问题。 JDB's threads command either hangs or executes extremely slowly. JDB的threads命令要么挂起,要么执行得非常慢。 The load on the remote JVM is reasonable, and there aren't any breakpoints set. 远程JVM上的负载是合理的,并且没有设置任何断点。 There are many threads executing on this JVM concurrently (~2005 threads), and there may be some WAN latency, but there still needs to be a way to successfully use a remote debugger with it! 在这个JVM上同时执行许多线程(~2005个线程),并且可能存在一些WAN延迟,但仍然需要有一种方法可以成功使用远程调试器!

Observation. 观察。 I'm guessing this is related to inefficient transmission of thread information via TCPIP by the JVM's Java Debug Wire Protocol (JDWP) implementation, as the machine is on the other side of the planet on a WAN. 我猜这是关系到通过TCPIP由JVM的Java调试线协议(JDWP)实现的线程信息传递效率低下,因为机器在这个星球的WAN上的另一侧。 HOWEVER -- Windows Remote Desktop Connection to the same machine is acceptably fast and performant. 但是 - Windows远程桌面连接到同一台机器是可以接受的快速和高性能。 Given that, it seems that having to wait 45 minutes for Eclipse or JDB to list thread information on a JVM is unacceptable and likely a bug (or a very poorly implemented feature). 鉴于此,似乎等待45分钟让Eclipse或JDB在JVM上列出线程信息是不可接受的,并且可能是一个错误(或一个非常糟糕的实现功能)。

Possibly related to? 可能与?有关?

  1. http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6401245 - This looks like it was fixed and shouldn't be the issue anymore. http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6401245 - 这看起来已修复,不应再是问题了。 Plus the JVM is running on Windows Datacenter not Linux. 此外,JVM在Windows Datacenter而非Linux上运行。
  2. http://www.eclipsecon.org/2013/comment/reply/1153.html - Possible solution but requires the SAP JVM? http://www.eclipsecon.org/2013/comment/reply/1153.html - 可能的解决方案,但需要SAP JVM?
  3. https://github.com/vpotapev/jbreakpoint - Open source jdb interface but doesn't fix issue with Eclipse. https://github.com/vpotapev/jbreakpoint - 开源jdb接口,但不解决Eclipse的问题。

Question. 题。 Does anyone have any ideas how to make the thread data transmission more efficient so the JVM can be remote debugged effectively? 有没有人有任何想法如何使线程数据传输更高效,以便JVM可以有效地远程调试? Is this a bug in the JVM's Java Debugging Wire Protocol (JDWP)? 这是JVM的Java调试线协议(JDWP)中的错误吗?

Problem Details 问题细节

Java Version: Java版本:

C:\Users\Administrator>"C:\Program Files\Java\jdk1.7.0_60\bin\java" -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

Application Server. Application Server。 Happens with Weblogic 10g. 与Weblogic 10g一起发生。 Also happens with IBM WebSphere 8.5 IBM WebSphere 8.5也会发生这种情况

Eclipse. 日食。 Eclipse remote debugging hangs indefinitely when trying to populate the Debug view with thread information. 尝试使用线程信息填充Debug视图时,Eclipse远程调试无限期挂起。

JDB - Remote. JDB - 远程。 Java's jdb remote debugger hangs for upwards of 10 minutes when listing the threads with the thread command. 使用thread命令列出线程时,Java的jdb远程调试器会挂起超过10分钟。 Then it lists them VERY slowly (1 thread per second, would take 33 minutes to list them all). 然后它非常缓慢地列出它们(每秒1个线程,需要33分钟才能列出所有这些)。

"C:\Program Files\Java\jdk1.7.0_60\bin\jdb.exe -connect com.sun.jdi.SocketAttach:hostname=xxx.yyy.com,port=7777
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> threads
Group system: <<jdb hangs here trying to get thread information>>

JDB - Local. JDB - 本地。 Java's jdb remote debugger executes the threads command in 3 seconds when run on the JVM's local machine. 当在JVM的本地计算机上运行时,Java的jdb远程调试器在3秒内执行threads命令。

"C:\Program Files\Java\jdk1.7.0_60\bin\jdb.exe -connect com.sun.jdi.SocketAttach:hostname=xxx.yyy.com,port=7777
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb ...
> threads
Group system:
> threads
Group system:
  (java.lang.ref.Reference$ReferenceHandler)0x7484                                                                  Reference Handler
  (java.lang.ref.Finalizer$FinalizerThread)0x7485                                                                   Finalizer
  (java.lang.Thread)0x7486                                                                                          ...
GC Daemon
  (java.lang.Thread)0x748b                                                                                          RMI RenewClean-
...
>

After some investigation and packet sniffing, it appears that having a large number of threads in the remote process causes debugging packet congestion as well as a feedback loop of processing delays between the remote process debug agent and the remote debugger. 经过一些调查和数据包嗅探后,似乎远程进程中有大量线程会导致调试数据包拥塞以及远程进程调试代理和远程调试器之间处理延迟的反馈循环。 Basically, the JVM debugging agent isn't engineered for high latency connections or debugging a large number of threads remotely. 基本上,JVM调试代理不是为高延迟连接而设计的,也不是为远程调试大量线程而设计的。 It also doesn't make an attempt to compress thread/stack/variable update information to lower transfer time to the debugger. 它也不会尝试压缩线程/堆栈/变量更新信息以降低调试器的传输时间。

Our solution was eventually to add a thread debug mode to our product that reduced the various server thread pool sizes, then debugging was suddenly acceptably responsive again across overseas networks. 我们的解决方案最终是为我们的产品添加一个线程调试模式,减少了各种服务器线程池大小,然后调试突然在海外网络上再次响应。

A future suggestion to the Java community would be to add a thread filter feature to both Eclipse and the Java Debug Agent so that only information for threads of interest is transmitted to the debugger after each code step is signalled. 未来对Java社区的建议是向Eclipse和Java调试代理添加线程过滤器功能,以便在每个代码步骤发出信号后,只将感兴趣的线程的信息传输到调试器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM