zoukankan      html  css  js  c++  java
  • jvm之判断ygc耗时和频率

    Step1、找出所查java应用的进程编号

    jps -mlv | grep 应用名称 # 或者 ps -ef | grep 应用名称
    20848 com.lqz.test.Main -Dprogram=APP_/home/lqz/test/bin/.. -Xms4G -Xmx4G

    Step2、查看应用的gc概况

    1.  
      $ jstat -gcutil 20848 250 10
    2.  
      S0 S1 E O P YGC YGCT FGC FGCT GCT
    3.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    4.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    5.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    6.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    7.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    8.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    9.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    10.  
      56.25 0.00 52.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    11.  
      56.25 0.00 54.10 34.51 39.51 469204 5176.817 549 111.738 5288.555
    12.  
      56.25 0.00 56.11 34.51 39.51 469204 5176.817 549 111.738 5288.555
    13.  
      $

    jstat 详细用法:jstat - Java Virtual Machine Statistics Monitoring Tool,更多的java工具:JDK Tools and Utilities,更多jdk文档,请进入传送门

    jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]
    1.  
      -gcutil Option
    2.  
      Summary of Garbage Collection Statistics
    3.  
      Column Description
    4.  
      S0 Survivor space 0 utilization as a percentage of the space's current capacity.
    5.  
      S1 Survivor space 1 utilization as a percentage of the space's current capacity.
    6.  
      E Eden space utilization as a percentage of the space's current capacity.
    7.  
      O Old space utilization as a percentage of the space's current capacity.
    8.  
      P Permanent space utilization as a percentage of the space's current capacity.
    9.  
      YGC Number of young generation GC events.
    10.  
      YGCT Young generation garbage collection time.
    11.  
      FGC Number of full GC events.
    12.  
      FGCT Full garbage collection time.
    13.  
      GCT Total garbage collection time.

    Step3、查看应用的运行时间

    1.  
      $ ps -p 20848 -o etime
    2.  
      ELAPSED
    3.  
      7-12:41:04
    4.  
      $
    ps -p pid -o etime
    1.  
      CODE HEADER DESCRIPTION
    2.  
      etime ELAPSED elapsed time since the process was started, in the form [[dd-]hh:]mm:ss.

    Step4、计算ygc的平均耗时和时间间隔

    ygc平均耗时=YGCT/YGC(s)=5176.81/469204=0.011s=11ms

    ygc时间间隔=YGC/程序的运行时间=469204/(7*24*60*60 + 12*60*60 + 41*60 + 4 )=0.72s

    如果各项参数设置合理,系统没有超时日志出现,GC频率不高,GC耗时不高,那么没有必要进行GC优化;如果GC时间超过1〜3 秒,或者频繁G C ,则必须优化。如果满足下面的指标,则一般不需要进行GC:
    ■ Minor GC执行时间不到50ms;
    ■ Minor GC执行不频繁,约10秒一次;
    ■ Full GC执行时间不到1s;
    ■ Full GC执行频率不算频繁,不低于10分钟1次。

  • 相关阅读:
    HuanGe'Linux Store上线了!
    4555
    google 代码
    曾经红透半边天的郭盛华,如今却拿着月薪5千的工资过生活,网友:到底经历了什么?
    揭秘:AI人工智能和摩尔定律的后指数时代
    黑客开始跨界攻击了,网络安全的未来在云端
    传奇人物郭盛华:汽车黑客,远远比我们想象中还要恐怖
    Facebook再现丑闻,约100位应用程序开发人员偷看用户数据
    郭盛华现身北京机场,颇有IT男的风范,网友:疑似被招安了
    郭盛华:中国网络的守护神,美俄黑客也要俯首称臣
  • 原文地址:https://www.cnblogs.com/kabi/p/12124909.html
Copyright © 2011-2022 走看看