[In-depth understanding of JVM] 11. CMS log format + G1 log format + common parameters + fiber [draft]

1. CMS log format

CMS log analysis

Execute the command: java -Xms20M -Xmx20M -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC com.mashibing.jvm.c7_gc.T15_FullGC_Problem01

[GC (Allocation Failure) [ParNew: 6144K->640K(6144K), 0.0265885 secs] 6585K->2770K(19840K), 0.0268035 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]

ParNew: Young Generation Collector

6144->640: Comparison before and after collection

(6144): The entire young generation capacity

6585 -> 2770: The situation of the entire heap

(19840): The entire heap size

[GC (CMS Initial Mark) [1 CMS-initial-mark: 8511K(13696K)] 9866K(19840K), 0.0040321 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 
	//8511 (13696) : 老年代使用(最大)
	//9866 (19840) : 整个堆使用(最大)
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.018/0.018 secs] [Times: user=0.01 sys=0.00, real=0.02 secs] 
	//这里的时间意义不大,因为是并发执行
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
	//标记Card为Dirty,也称为Card Marking
[GC (CMS Final Remark) [YG occupancy: 1597 K (6144 K)][Rescan (parallel) , 0.0008396 secs][weak refs processing, 0.0000138 secs][class unloading, 0.0005404 secs][scrub symbol table, 0.0006169 secs][scrub string table, 0.0004903 secs][1 CMS-remark: 8511K(13696K)] 10108K(19840K), 0.0039567 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
	//STW阶段,YG occupancy:年轻代占用及容量
	//[Rescan (parallel):STW下的存活对象标记
	//weak refs processing: 弱引用处理
	//class unloading: 卸载用不到的class
	//scrub symbol(string) table: 
	//cleaning up symbol and string tables which hold class-level metadata and 
	//internalized string respectively
	//CMS-remark: 8511K(13696K): 阶段过后的老年代占用及容量
	//10108K(19840K): 阶段过后的堆占用及容量

[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.005/0.005 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
	//标记已经完成,进行并发清理
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
	//重置内部结构,为下次GC做准备

 

2. G1 log format

G1

  1. https://www.oracle.com/technical-resources/articles/java/g1gc.html

G1 log details YGC MinedGC FGC

[GC pause (G1 Evacuation Pause) (young) (initial-mark), 0.0015790 secs]
//young -> 年轻代 Evacuation-> 复制存活对象 
//initial-mark 混合回收的阶段,这里是YGC混合老年代回收
   [Parallel Time: 1.5 ms, GC Workers: 1] //一个GC线程
      [GC Worker Start (ms):  92635.7]
      [Ext Root Scanning (ms):  1.1]
      [Update RS (ms):  0.0]
         [Processed Buffers:  1]
      [Scan RS (ms):  0.0]
      [Code Root Scanning (ms):  0.0]
      [Object Copy (ms):  0.1]
      [Termination (ms):  0.0]
         [Termination Attempts:  1]
      [GC Worker Other (ms):  0.0]
      [GC Worker Total (ms):  1.2]
      [GC Worker End (ms):  92636.9]
   [Code Root Fixup: 0.0 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.0 ms]
   [Other: 0.1 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 0.0 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.0 ms]
      [Humongous Register: 0.0 ms]
      [Humongous Reclaim: 0.0 ms]
      [Free CSet: 0.0 ms]
   [Eden: 0.0B(1024.0K)->0.0B(1024.0K) Survivors: 0.0B->0.0B Heap: 18.8M(20.0M)->18.8M(20.0M)]
 [Times: user=0.00 sys=0.00, real=0.00 secs] 
//以下是混合回收其他阶段
[GC concurrent-root-region-scan-start]
[GC concurrent-root-region-scan-end, 0.0000078 secs]
[GC concurrent-mark-start]
//无法evacuation,进行FGC
[Full GC (Allocation Failure)  18M->18M(20M), 0.0719656 secs]
   [Eden: 0.0B(1024.0K)->0.0B(1024.0K) Survivors: 0.0B->0.0B Heap: 18.8M(20.0M)->18.8M(20.0M)], [Metaspace: 38
76K->3876K(1056768K)] [Times: user=0.07 sys=0.00, real=0.07 secs]

3. Common parameters

GC commonly used parameters

  • -Xmn -Xms -Xmx -Xss young generation minimum heap maximum stack space
  • -XX:+UseTLAB use TLAB, open by default
  • -XX:+PrintTLAB Print the usage of TLAB
  • -XX:TLABSize set TLAB size
  • -XX:+DisableExplictGC System.gc() does not work, FGC
  • -XX:+PrintGC
  • -XX:+PrintGCDetails
  • -XX:+PrintHeapAtGC
  • -XX:+PrintGCTimeStamps
  • -XX:+PrintGCApplicationConcurrentTime (low) print application time
  • -XX:+PrintGCApplicationStoppedTime (low) print pause time
  • -XX:+PrintReferenceGC (low importance) records how many references of different reference types have been recovered
  • -verbose:class class loading detailed process
  • -XX:+PrintVMOptions
  • -XX:+PrintFlagsFinal -XX:+PrintFlagsInitial must be used
  • -Xloggc:opt/log/gc.log
  • -XX:MaxTenuringThreshold upgrade age, the maximum value is 15
  • Number of lock spins-XX:PreBlockSpin hot code detection parameter-XX:CompileThreshold escape analysis scalar replacement...These are not recommended to be set

Parallel common parameters

  • -XX: SurvivorRatio (mediation 8:1:1 ratio)
  • -XX: PreTenureSizeThreshold How big is the large object?
  • -XX:MaxTenuringThreshold
  • -XX:+ParallelGCThreads Parallel collector thread number, also applicable to CMS, generally set to be the same as the number of CPU cores
  • -XX:+UseAdaptiveSizePolicy automatically selects the size ratio of each area

CMS common parameters

  • -XX:+UseConcMarkSweepGC
  • -XX: ParallelCMSThreads CMS thread number
  • -XX:CMSInitiatingOccupancyFraction What percentage of the old generation to use before starting CMS collection, the default is 68% (approximate value), if SerialOld lag occurs frequently, it should be reduced (frequent CMS recovery)
  • -XX:+UseCMSCompactAtFullCollection is compressed at FGC (in fact, compressed at CMS)
  • -XX:CMSFullGCsBeforeCompaction How many times does FGC perform compression
  • -XX:+CMSClassUnloadingEnabled
  • -XX: CMSInitiatingPermOccupancyFraction Perm recovery when reaching what proportion
  • GCTimeRatio Set the percentage of GC time that occupies the running time of the program
  • -XX:MaxGCPauseMillis pause time is a suggested time. GC will try to achieve this time by various means, such as reducing the young generation

G1 common parameters

  • -XX:+UseG1GC
  • -XX:MaxGCPauseMillis recommended value, G1 will try to adjust the number of blocks in the Young area to reach this value
  • -XX:GCPauseIntervalMillisGC's pause interval target
  • -XX:+G1HeapRegionSize partition size, it is recommended to increase the value gradually, 1 2 4 8 16 32. As the size increases, the garbage survival time is longer and the GC interval is longer, but the time of each GC will be longer. ZGC has made improvements (dynamic block size)
  • G1NewSizePercent The minimum proportion of the new generation, the default is 5%
  • G1MaxNewSizePercent The maximum proportion of the new generation, the default is 60%
  • GCTimeRatio GC time recommended ratio, G1 will adjust the heap space according to this value
  • ConcGCThreads number of threads
  • InitiatingHeapOccupancyPercent Start G1 heap space occupation ratio

4. Fiber

Guess you like

Origin blog.csdn.net/zw764987243/article/details/109612315