gc details

426 views
Skip to first unread message

melod...@gmail.com

unread,
Sep 13, 2017, 10:39:31 PM9/13/17
to golang-dev
Hi, 

I am learning how gc works in go. I saw this part in glang.org. That is exactly I want to know. But they did not show this in the post. I wonder if there are any documents for the details??


"Of course the devil is in the details. When do we start a GC cycle? What metrics do we use to make that decision? How should the GC interact with the Go scheduler? How do we pause a mutator thread long enough to scan its stack?  How do we represent white, grey, and black so we can efficiently find and scan grey objects? How do we know where the roots are? How do we know where in an object pointers are located? How do we minimize memory fragmentation? How do we deal with cache performance issues? How big should the heap be? And on and on, some related to allocation, some to finding reachable objects, some related to scheduling, but many related to performance. Low-level discussions of each of these areas are beyond the scope of this blog post."


Thanks a lot 

Melody

Austin Clements

unread,
Sep 14, 2017, 12:41:13 AM9/14/17
to melod...@gmail.com, golang-dev
That's a lot of questions. :)

I would recommend starting with the big comments at the top of runtime/malloc.go (which describes the allocator) and runtime/mgc.go (which describes the garbage collector). runtime/mbarrier.go and runtime/mbitmap.go are also relevant.

Many of the scheduling questions are answered by golang.org/s/go15gcpacing.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

melod...@gmail.com

unread,
Sep 14, 2017, 1:18:02 PM9/14/17
to golang-dev
Hi Austin,

:) Thanks a lot for your reply for so many questions :)

Thanks
Melody
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.

Wei....@arm.com

unread,
Oct 13, 2017, 2:49:23 AM10/13/17
to golang-dev
Just ask a basic question:
If there is a function:foo which is doing a lot of computation without calling to any other functions (let's suppose it will run for several minutes).
During the execution of the function, other goroutine triggers GC but the STW can't take the goroutine executing the foo.
Then what will happen? crash?

Thanks
Wei Xiao
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.

Dave Cheney

unread,
Oct 13, 2017, 3:20:24 AM10/13/17
to Wei....@arm.com, golang-dev
The STW phase will block and the application will experience a serious latency issue. 

David Chase

unread,
Oct 13, 2017, 9:31:35 AM10/13/17
to Dave Cheney, Wei....@arm.com, golang-dev
And we are working on that problem, but having a hard time with the overhead that imposes on very small loops.

To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.

Ian Lance Taylor

unread,
Oct 13, 2017, 10:25:57 AM10/13/17
to David Chase, Dave Cheney, Wei....@arm.com, golang-dev
On Fri, Oct 13, 2017 at 6:31 AM, 'David Chase' via golang-dev
<golan...@googlegroups.com> wrote:
> And we are working on that problem, but having a hard time with the overhead
> that imposes on very small loops.

This work is being tracked in https://golang.org/issue/10958 .

Ian
Reply all
Reply to author
Forward
0 new messages