times of stw in one gc cycle?

184 views
Skip to first unread message

xie cui

unread,
Jun 6, 2021, 7:18:56 AM6/6/21
to golang-nuts
https://github.com/golang/go/blob/master/src/runtime/mgc.go#L858-L876
due to these code lines, stw in one gc cycle may happen more than 2 times. so stw times  in one gc cycle could be 2(general), 3, 4, .... and even for ever?

Ian Lance Taylor

unread,
Jun 7, 2021, 6:00:11 PM6/7/21
to xie cui, golang-nuts
On Sun, Jun 6, 2021 at 4:19 AM xie cui <cuiw...@gmail.com> wrote:
>
> https://github.com/golang/go/blob/master/src/runtime/mgc.go#L858-L876
> due to these code lines, stw in one gc cycle may happen more than 2 times. so stw times in one gc cycle could be 2(general), 3, 4, .... and even for ever?

Theoretically, yes. In practice, this is not a problem.

Ian

Rick Hudson

unread,
Jun 12, 2021, 9:30:14 AM6/12/21
to golang-nuts
It won't go on forever.  The formal proofs are in the original Sapphire and distributed Train algorithm papers. Informally the proofs show that there is no way to create a new white object, no way to pass white object between threads more than a bounded number of times, reachable non-black objects are bounded, and each loop discovers and extinguishes at least one non-black reachable object.

Richard L. Hudson and J. Eliot B. Moss, ``Sapphire: Copying GC Without Stopping the World,'' Concurrency and Computation: Practice and Experience, Volume 15, Issue 3-5, pp. 223-261, John Wiley and Sons, 2003. http://dx.doi.org/10.1002/cpe.712.
Reply all
Reply to author
Forward
0 new messages