golang 打印gc信息

启动命令

GODEBUG='gctrace=1' nohup ./app &

日志信息


[GIN-debug] Listening and serving HTTP on :8000
GC forced
gc 2 @123.080s 0%: 0.052+7.6+0.002 ms clock, 3->3->2 MB, 4 MB goal, 0 MB stacks, 0 MB globals, 8 P
GC forced
gc 3 @243.101s 0%: 0.091+0.40+0.002 ms clock, 0.72+0/0.70/1.7+0.018 ms cpu, 2->2->2 MB, 4 MB goal, 0 MB stacks, 0 MB globals, 8 P
 

官方参数解释

Currently, it is:
    gc # @#s #%: #+#+# ms clock, #+#/#/#+# ms cpu, #->#-># MB, # MB goal, # P
where the fields are as follows:
    gc #        the GC number, incremented at each GC
    @#s         time in seconds since program start
    #%          percentage of time spent in GC since program start
    #+...+#     wall-clock/CPU times for the phases of the GC
    #->#-># MB  heap size at GC start, at GC end, and live heap
    # MB goal   goal heap size
    # P         number of processors used
The phases are stop-the-world (STW) sweep termination, concurrent
mark and scan, and STW mark termination. The CPU times
for mark/scan are broken down in to assist time (GC performed in
line with allocation), background GC time, and idle GC time.
If the line ends with "(forced)", this GC was forced by a
runtime.GC() call and all phases are STW.

gc 2 第2次gc。

@123.080s runtime启动到现在的时间。

0%gc的标记工作(包括两次mark阶段的STW和并发标记)所用的CPU时间占总CPU的百分比。

0.052+7.6+0.002 ms clock按顺序分成三部分,0.052表示mark阶段的STW时间(单P的);7.6表示并发标记用的时间(所有P的);0.002 表示markTermination阶段的STW时间(单P的)。

0.41+0/0.80/9.1+0.018 ms cpu按顺序分成三部分,0.41表示整个进程在mark阶段STW停顿时间(0.052* 8);0/0.80/9.1有三块信息,0是mutator assists占用的时间,0.80是dedicated mark workers+fractional mark worker占用的时间,9.1是idle mark workers占用的时间。这三块时间加起来会接近7.6*8(P的个数);0.018 ms表示整个进程在markTermination阶段STW停顿时间(0.018 * 8)。

3->3->2 MB按顺序分成三部分,3表示开始mark阶段前的heap_live大小;3表示开始markTermination阶段前的heap_live大小;2表示被标记对象的大小。

4MB goal表示下一次触发GC的内存占用阀值是4MB,等于2MB * 2

8 P本次gc共有多少个P。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值