分析 Sun Hotspots、JVM 6 的 GC 日志

发布于 2024-08-13 11:33:36 字数 668 浏览 1 评论 0原文

我正在尝试分析我们的应用程序的 GC 行为(在 Tomcat 中运行,在 Sun 热点JVM 1.6 下)。

到目前为止,我已经指示 JVM 使用...将 GC 日志发送到单独的文件,

-Xloggc:gc.log 
-XX:+PrintGCApplicationStoppedTime 
-XX:+PrintGCApplicationConcurrentTime 
-XX:+PrintGC 
-XX:+PrintGCTimeStamps 
-XX:+PrintGCDetails

并使用 jstat 输出日志,使用...

jstat -gc -t 29045 5s > jstat.gc

我看到了有趣的信息,但还没有找到一个工具来帮助我分析/可视化这些日志。 这个问题向我指出了 GCViewer,但是它只解析 gc.log 中的几行日志,然后因异常而崩溃。对于我正在使用的特定 JVM,是否有更好或更最新的工具来解析这些特定日志?

I'm trying to analyze GC behaviour for our application (running in Tomcat, under Sun's Hotspots, JVM 1.6).

So far I've Instructed the JVM to emit GC logs to a separate file using...

-Xloggc:gc.log 
-XX:+PrintGCApplicationStoppedTime 
-XX:+PrintGCApplicationConcurrentTime 
-XX:+PrintGC 
-XX:+PrintGCTimeStamps 
-XX:+PrintGCDetails

...and used jstat to output logs using...

jstat -gc -t 29045 5s > jstat.gc

I am seeing interesting information, but haven't found a tool to help me analyze/visualize these logs. I was pointed to GCViewer by this question, but it only parses a few log lines from gc.log and then crashes with an exception. Is there a better or more up-to-date tool for parsing these specific logs, for the specific JVM I'm using?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

染柒℉ 2024-08-20 11:33:36

gcviewer 已经很多年没有更新了,所以它时好时坏——一些 gc 文件可以正常工作,另一些则出现异常。

IBM 的 gc 日志解析器工作正常,
http://www.alphaworks.ibm.com/tech/pmat/faq

Sun 有一个叫做 GCPortal 的东西,但它需要:

  • 安装到 Web 应用程序服务器中
  • 安装 awk 和 perl
  • 安装带有 JDBC 驱动程序和配置的 RDBMS
  • ,以及真正的杀手级第三方图形/图表软件,以前是免费的,现在是免费的不是。
    惊人的。

gchisto 已经死了,项目中不再有任何东西。

HPJmeter 不理解 IBM gc 文件。

gcviewer hasn't been updated in a number of years, so it's hit or miss - some gc files will work fine, others get exceptions.

IBM's gc log parser works acceptably,
http://www.alphaworks.ibm.com/tech/pmat/faq

Sun has something called GCPortal, but it requires:

  • install into a web app server
  • install of awk and perl
  • install of a RDBMS with a JDBC driver and configuration
  • and the real killer, third-party graph/chart software that used to be free and now isn't.
    Amazing.

gchisto has died, there's no longer anything in the project.

HPJmeter doesn't understand IBM gc files.

月光色 2024-08-20 11:33:36

IBM Support Assistant 中提供的工具做得非常好。

The tools available in the IBM Support Assistant do a pretty good job.

无需解释 2024-08-20 11:33:36

我个人使用 HP JMeter 进行大量 GC可视化。它在 SUN JRE 上运行“正常”,在 HP 的 JRE 上运行得非常好(见图)。

对于 Sun HotSpot 1.6(在非 HP 平台上),我使用这些 GC 选项来生成日志以供分析:

-Xloggc:/path/to/vgc/log/location/logfile.vgc  --XX:+PrintHeapAtGC 

I personally use HP JMeter for a lot of GC visualization. it works "ok" on SUN JRE's, and exceptionally well on HP's JRE (go figure).

With Sun HotSpot 1.6 (on non-HP platforms), I use these GC Options to produce the logs for analysis:

-Xloggc:/path/to/vgc/log/location/logfile.vgc  --XX:+PrintHeapAtGC 
靑春怀旧 2024-08-20 11:33:36

你看过jvisualvm吗?附带最新的JDK,并允许您观看JVM。示例输出(使用 visualGC 插件)。示例输出 - 替代文本 http://g4u0420c.houston.hp .com/en/5992-4687/img/visualgc_2.png

Have you looked at jvisualvm? Comes with the latest JDK, and allows you to watch the JVM. Sample output (using the visualGC plugin). Sample output - alt text http://g4u0420c.houston.hp.com/en/5992-4687/img/visualgc_2.png

不喜欢何必死缠烂打 2024-08-20 11:33:36

我尝试使用 Visual GC,但它似乎适用于 id 进程(jvm 或 jstatd 进程)。我不能将它与 jstat.gc 一起使用,我的意思是文件而不是流
对吗?

I tried to use Visual GC, but it seems to work with an id process (the jvm one ou jstatd one). I can't use it with a jstat.gc, I mean a file and not a stream
Is it right?

我最亲爱的 2024-08-20 11:33:36

尝试使用 gchisto (gchisto.dev.java.net)。它可以理解GC日志输出(我不确定它是否已更新以与G1 GC一起使用)。你必须从 CVS 获取源代码(你需要一个 dev.java.net 帐户)并自己构建它

Try using gchisto (gchisto.dev.java.net). It can understand the GC log output (I am not sure whether it has been updated to work with the G1 GC). You have to get the sources from CVS (you need a dev.java.net account for that) and build this yourself

风向决定发型 2024-08-20 11:33:36

这是一个 0.00 美元的日志抓取工具,适用于 1.5 CMS 收集器,它为您提供 GC 暂停的高级视图。

您可能需要将位置参数 $7 参数更改为时间戳函数,以便匹配您的日志行语法(我的 .out 通过 Tanuki Wrapper 得到“增强”)。

#! /usr/bin/awk -f
# Awk script to parse .out logs and print total of
# stop-the-world GC pause times in ten minute intervals

BEGIN {print "t\timark\tmark\tremark\tfullgc"}

/CMS-initial-mark:/ {
  t=timestamp($7);
  imark[t] += $(NF-1);
}

/\[CMS-concurrent-mark:/ {
  t=timestamp($7);
  split($(NF-1), b, "/");
#  print t" NF="NF" val="b[1];
  mark[t] += b[1];
}

/CMS-remark/ {
  t=timestamp($7);
  remark[t] += $(NF-1);
}

/\[Full GC / {
  t=timestamp($7);
  level=0;
  for (i=1; i<=NF; i++) {
      if ($i ~ /\[/) {
        level++;
      } else if ($i ~ /\]/) {
        level--;
      }
  }
  while (level > 0) {
    getline;
    for (i=1; i<=NF; i++) {
      if ($i ~ /\[/) {
        level++;
      } else if ( $i ~ /\]/ ) {
        level-- ;
      }
    }
  }
  if ( $(NF) ~ /secs\]/ ) {
    full[t] += $(NF-1) ;
  }
}

function timestamp(str) {
  split(str, a, ":");
  return a[1]":"substr(a[2],0,length(a[2])-1)"0";
}

# print out UK+US trading hours

END {
  for (hour = 5; hour <= 16; hour++) {
    for (minute = 0; minute <= 59; minute+=10) {
      t = sprintf("%02d:%02d", hour, minute);
      printf "%s\t%d\t%d\t%d\t%d\n", t, imark[t], mark[t], remark[t], full[t];
    }
  }
}

Here is a $0.00 log scraper good for 1.5 CMS collector which gives you a high level view of GC pauses.

You may need to change positional parameter $7 argument to the timestamp function in order to match your log line syntax (my .out gets "enhanced" by Tanuki Wrapper).

#! /usr/bin/awk -f
# Awk script to parse .out logs and print total of
# stop-the-world GC pause times in ten minute intervals

BEGIN {print "t\timark\tmark\tremark\tfullgc"}

/CMS-initial-mark:/ {
  t=timestamp($7);
  imark[t] += $(NF-1);
}

/\[CMS-concurrent-mark:/ {
  t=timestamp($7);
  split($(NF-1), b, "/");
#  print t" NF="NF" val="b[1];
  mark[t] += b[1];
}

/CMS-remark/ {
  t=timestamp($7);
  remark[t] += $(NF-1);
}

/\[Full GC / {
  t=timestamp($7);
  level=0;
  for (i=1; i<=NF; i++) {
      if ($i ~ /\[/) {
        level++;
      } else if ($i ~ /\]/) {
        level--;
      }
  }
  while (level > 0) {
    getline;
    for (i=1; i<=NF; i++) {
      if ($i ~ /\[/) {
        level++;
      } else if ( $i ~ /\]/ ) {
        level-- ;
      }
    }
  }
  if ( $(NF) ~ /secs\]/ ) {
    full[t] += $(NF-1) ;
  }
}

function timestamp(str) {
  split(str, a, ":");
  return a[1]":"substr(a[2],0,length(a[2])-1)"0";
}

# print out UK+US trading hours

END {
  for (hour = 5; hour <= 16; hour++) {
    for (minute = 0; minute <= 59; minute+=10) {
      t = sprintf("%02d:%02d", hour, minute);
      printf "%s\t%d\t%d\t%d\t%d\n", t, imark[t], mark[t], remark[t], full[t];
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文