How many times gc stw ?

113 views
Skip to first unread message

Chou Yan

unread,
Jun 20, 2019, 12:56:36 PM6/20/19
to golang-nuts
I look up the doc for gctrace:
it show us:

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.

I am very confused. Will it be swt in the cleanup phase?
And how many times gc stw? mark start? concurrent mark? remark ? or sweep ?

Ian Lance Taylor

unread,
Jun 20, 2019, 8:54:31 PM6/20/19
to Chou Yan, golang-nuts
I'm sorry, I don't understand what you are asking. What is the cleanup phase?

> And how many times gc stw? mark start? concurrent mark? remark ? or sweep ?

See the long comment near the top of runtime/mgc.go. Currently each
cycle stops the world twice, very briefly, in the sweep termination
and mark termination phases.

Ian

Chou Yan

unread,
Jun 20, 2019, 10:00:30 PM6/20/19
to golang-nuts
Sorry. 
Which I understand is that 'sweep termination = clean up = release the physical memory'
The long comment is helpful.
I got 
'b. Sweep any unswept spans. There will only be unswept spans if this GC cycle was forced before the expected time.'
Dose it means 'sweep = scan the root span', like java cms 'gc root scan'? not the release the physical memory?

在 2019年6月21日星期五 UTC+8上午8:54:31,Ian Lance Taylor写道:

Chou Yan

unread,
Jun 20, 2019, 10:22:13 PM6/20/19
to golang-nuts
The describe 'release the physical memory' may not be rigorous. Because gc remand the span,obj, or big obj to heap or central area, may not release the physical memory.
"When the next GC starts, it sweeps all not-yet-swept spans (if any)."
maybe it is the sweeps termination phrase mean.
BTW, I look the doc and look up three time of stw.
sweep termination 
GC performs the mark phase. No objects may be
//    scanned until all Ps have enabled the write barrier, which is
// accomplished using STW.
mark termination phases. 
or "write barrier" accomplished during sweep termination?  
在 2019年6月21日星期五 UTC+8上午8:54:31,Ian Lance Taylor写道:

Ian Lance Taylor

unread,
Jun 21, 2019, 12:37:17 AM6/21/19
to Chou Yan, golang-nuts
On Thu, Jun 20, 2019 at 7:00 PM Chou Yan <yan.cho...@gmail.com> wrote:
>
> Sorry.
> Which I understand is that 'sweep termination = clean up = release the physical memory'
> The long comment is helpful.
> I got
> 'b. Sweep any unswept spans. There will only be unswept spans if this GC cycle was forced before the expected time.'
> Dose it means 'sweep = scan the root span', like java cms 'gc root scan'? not the release the physical memory?

If I understand you correctly, the answer is yes. Physical memory is
released by the scavenger. On tip see runtime/mgcscavenge.go.

Ian

Ian Lance Taylor

unread,
Jun 21, 2019, 12:38:50 AM6/21/19
to Chou Yan, golang-nuts
On Thu, Jun 20, 2019 at 7:22 PM Chou Yan <yan.cho...@gmail.com> wrote:
>
> The describe 'release the physical memory' may not be rigorous. Because gc remand the span,obj, or big obj to heap or central area, may not release the physical memory.
> "When the next GC starts, it sweeps all not-yet-swept spans (if any)."
> maybe it is the sweeps termination phrase mean.
> BTW, I look the doc and look up three time of stw.
> sweep termination
>
> GC performs the mark phase. No objects may be
>
> // scanned until all Ps have enabled the write barrier, which is
> // accomplished using STW.
>
> mark termination phases.
> or "write barrier" accomplished during sweep termination?

The write barrier is enabled as sweep termination completes.

Ian

Chou Yan

unread,
Jun 21, 2019, 6:04:23 AM6/21/19
to golang-nuts
thx

在 2019年6月21日星期五 UTC+8下午12:38:50,Ian Lance Taylor写道:
Reply all
Reply to author
Forward
0 new messages