JProfiler 11 离线分析:快照定时器触发器不工作

JProfiler 11 Offline Profiling: Timer Trigger for Snapshot not working

我尝试对远程主机上的 Java 8 应用程序进行离线分析,但不允许我直接访问。 (Hadoop 集群上的 Flink YARN 作业)。

我能够通过 JProfiler -> 会话 -> 集成向导 -> 新的远程集成 -> 执行一些步骤然后 [=33] 从 JProfiler 中导出相关的 JProfiler 库以进行离线调试 linux 64 =]. 我将未提取的存档部署到所有主机上的 /JPROFILER,然后为整个目录结构递归设置 755。

然后我在我的主机上用 2 个定时器触发器创建了一个会话。一个在 2 分钟后激活跟踪,另一个在 22 分钟后停止所有跟踪并保存快照。当我 运行 JProfiler GUI 中的这个会话通过 SSH 连接到某个任意远程主机时,它似乎工作正常。在状态栏,我看到2分钟后,3条记录是运行ning,22分钟后,0条记录是运行ning。但是当我尝试在没有 GUI 的情况下在离线分析中使用该会话时,它不起作用。

为了在集群上进行离线分析,我使用适当的选项启动了我的 YARN 应用程序,并确保启动的 JVM 具有:

-agentpath:/JPROFILER/jprofiler11/bin/linux-x64/libjprofilerti.so=offline,id=123,config=/JPROFILER/jprofiler_config.xml

设置。从 YARN 容器日志来看,这似乎工作正常,我在 stderr 中看到:

JProfiler> Protocol version 63
JProfiler> Java 8 detected.
JProfiler> Offline profiling mode.
JProfiler> 64-bit library
JProfiler> Using config file /JPROFILER/jprofiler_config.xml (id: 123)
JProfiler> Listening on port: 8849.
JProfiler> Enabling native methods instrumentation.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Using sampling (2 ms)
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
SLF4J: Class path contains multiple SLF4J bindings.
... Some SLF4J stuff, no more JProfiler or other messages ...

然而,快照文件不知何故从未保存,也许 none 两个触发器都被触发了(我无法检查记录是否开始或快照保存不工作)。我试图在 /tmp 中的 JVM 进程工作目录中找到快照,我什至通过以下方式搜索了整个主机:

find / -iname "*flink-taskmanager-snapshot*" 2>/dev/null

但我什么也没找到。没有进一步的消息被写入 stderr,即使我的触发器被配置为打印一些东西到 stderr。

您知道为什么 triggers/snapshot 不起作用吗? JProfiler 似乎初始化得很好。 这是 jprofiler_config.xml :

<?xml version="1.0" encoding="UTF-8"?>
<config version="11.1">
  <sessions>
    <session id="123" name="Flink-TaskManager-JProfiler" type="remote" remoteType="ssh" timeout="5" jvmConfigurationId="100" samplingFrequency="2" recordArrayAlloc="false" compilationMode="manual" compilationTarget="1.8">
      <filters>
        <group type="exclusive" name="Default excludes" template="none">
          <filter type="exclusive" name="$Proxy" />
          <!-- ... stripped ... -->
          <filter type="exclusive" name="workshop." />
        </group>
      </filters>
      <triggers logTarget="stderr" logFile="">
        <timer descriptionType="manual" manualDescription="Start recording" offsetTime="2" intervalTime="2" type="limited">
          <actions>
            <startRecording>
              <cpu enabled="true" />
              <allocation enabled="true" />
              <thread enabled="true" />
              <telemetry enabled="true" />
            </startRecording>
            <startCallTracer />
            <startProbeRecording name="builtin.HttpClientProbe" events="true" />
            <printMessage message="JProfiler: Start tracking" />
          </actions>
        </timer>
        <timer descriptionType="manual" manualDescription="stop recording" offsetTime="22" intervalTime="22" type="limited">
          <actions>
            <stopRecording>
              <cpu enabled="true" />
              <allocation enabled="true" />
              <thread enabled="true" />
              <telemetry enabled="true" />
            </stopRecording>
            <stopCallTracer />
            <stopProbeRecording name="builtin.HttpClientProbe" />
            <saveSnapshot file="flink-taskmanager-snapshot" number="true" />
            <printMessage message="JProfiler: stop recording and save snapshot..." />
          </actions>
        </timer>
      </triggers>
      <probes>
        <probe name="builtin.TrackingInterceptor">
          <id value="1" />
          <id value="2" />
          <id value="5" />
          <id value="7" />
        </probe>
      </probes>
      <ssh port="43490" verifyHosts="false">
        <entry hostName="some-remote-for-tests" userName="yarn" authentication="key" keyFile="C:\Users\theo\.ssh\id_rsa" />
      </ssh>
    </session>
  </sessions>
</config>

这里是关于我的 java 版本的输出:

$ /usr/java/jdk1.8.0_181-cloudera/bin/java -XshowSettings:properties -version
Property settings:
    awt.toolkit = sun.awt.X11.XToolkit
    file.encoding = ANSI_X3.4-1968
    file.encoding.pkg = sun.io
    file.separator = /
    java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
    java.awt.printerjob = sun.print.PSPrinterJob
    java.class.path = .
    java.class.version = 52.0
    java.endorsed.dirs = /usr/java/jdk1.8.0_181-cloudera/jre/lib/endorsed
    java.ext.dirs = /usr/java/jdk1.8.0_181-cloudera/jre/lib/ext
        /usr/java/packages/lib/ext
    java.home = /usr/java/jdk1.8.0_181-cloudera/jre
    java.io.tmpdir = /tmp
    java.library.path = /usr/java/packages/lib/amd64
        /usr/lib64
        /lib64
        /lib
        /usr/lib
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.8.0_181-b13
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Oracle Corporation
    java.specification.version = 1.8
    java.vendor = Oracle Corporation
    java.vendor.url = http://java.oracle.com/
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    java.version = 1.8.0_181
    java.vm.info = mixed mode
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Oracle Corporation
    java.vm.specification.version = 1.8
    java.vm.vendor = Oracle Corporation
    java.vm.version = 25.181-b13
    line.separator = \n
    os.arch = amd64
    os.name = Linux
    os.version = 3.10.0-1062.4.1.el7.x86_64
    path.separator = :
    sun.arch.data.model = 64
    sun.boot.class.path = /usr/java/jdk1.8.0_181-cloudera/jre/lib/resources.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/lib/rt.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/lib/sunrsasign.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/lib/jsse.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/lib/jce.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/lib/charsets.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/lib/jfr.jar
        /usr/java/jdk1.8.0_181-cloudera/jre/classes
    sun.boot.library.path = /usr/java/jdk1.8.0_181-cloudera/jre/lib/amd64
    sun.cpu.endian = little
    sun.cpu.isalist =
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = ANSI_X3.4-1968
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers
    sun.os.patch.level = unknown
    user.country = US
    user.dir = /var/lib/hadoop-yarn
    user.home = /root
    user.language = en
    user.name = root
    user.timezone =

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

我找到了它,这是 JProfiler 11 和 11.1 中用于离线分析的错误。

所有计时器及其在离线分析中的操作都可以正常工作,如果它们不受限制,即定期安排。 XML 看起来像

<timer offsetTimeUnit="s" intervalTime="10" intervalTimeUnit="s">
  <actions>
    <printMessage message="JProfiler Debug working?" />
  </actions>
</timer>

它也有效,如果我设置有限的执行次数 !=1 那么配置 XML 将如下所示:

<timer manualDescription="Start recording" offsetTime="30" offsetTimeUnit="s" intervalTime="30" intervalTimeUnit="s" type="limited" count="2">
  <actions>
    <printMessage message="JProfiler: Start tracking" />
  </actions>
</timer>

但是,如果重复计数设置为 1,JProfiler 配置 XML 将不会存储 timer 元素的 count 属性,可能是因为它是默认值。该轮的离线分析器不会执行任何重复,而相比之下,JProfiler UI 将执行触发器 1 次。

总结:手动编辑 jprofiler_config.xml 并将 count=1 作为属性添加到我的 timer 可以解决这里的问题。 希望JProfiler 尽快修复该错误。我在他们的主页上报告了这个错误。

编辑 在周末报告错误后仅 4 小时,我收到了错误修复版本,正如评论所说,JProfiler 11.1.1 将修复此问题。我把这个 post 放在这里只是作为一个关于如何设置离线分析(在 FLink/YARN 中)的简短教程,以及为使用 JProfiler 11.0 的人作为升级提醒。