Mark Termination - STW:Mark完成后,需要关闭Write Barrier,进行多项清理工作,设定下次collection的目标。在进行这些工作前,仍要求所有的goroutine停止。这些工作平均持续60~90ms。虽然也可以设计成边Termination边正常运行一些gorutine的模式,但是设计者认为这样得到的收益很小,而增加的复杂性较高,所以选择了这种STW的实现方式。当Termination工作完成后,回到正常状态。
gc 1405 @6.068s 11%: 0.058+1.2+0.083 ms clock, 0.70+2.5/1.5/0+0.99 ms cpu, 7->11->6 MB, 10 MB goal, 12 P
gc 1406 @6.070s 11%: 0.051+1.8+0.076 ms clock, 0.61+2.0/2.5/0+0.91 ms cpu, 8->11->6 MB, 13 MB goal, 12 P
gc 1407 @6.073s 11%: 0.052+1.8+0.20 ms clock, 0.62+1.5/2.2/0+2.4 ms cpu, 8->14->8 MB, 13 MB goal, 12 P
# GC trace含义 gc 1405 @6.068s 11%: 0.058+1.2+0.083 ms clock, 0.70+2.5/1.5/0+0.99 ms cpu, 7->11->6 MB, 10 MB goal, 12 P
// General gc 1404 : The 1404 GC run since the program started @6.068s : Six seconds since the program started 11% : Eleven percent of the available CPU so far has been spent in GC
// Wall-Clock 0.058ms : STW : Mark Start - Write Barrier on 1.2ms : Concurrent : Marking 0.083ms : STW : Mark Termination - Write Barrier off and clean up
// CPU Time 0.70ms : STW : Mark Start 2.5ms : Concurrent : Mark - Assist Time (GC performed in line with allocation) 1.5ms : Concurrent : Mark - Background GC time 0ms : Concurrent : Mark - Idle GC time 0.99ms : STW : Mark Term
// Memory 7MB : Heap memory in-use before the Marking started 11MB : Heap memory in-use after the Marking finished 6MB : Heap memory marked as live after the Marking finished 10MB : Collection goal for heap memory in-use after Marking finished
// Threads 12P : Number of logical processors or threads used to run Goroutines