Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4136)

Issue 46430043: code review 46430043: runtime: concurrent GC sweep (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 3 months ago by dvyukov
Modified:
10 years, 1 month ago
CC:
golang-codereviews, Sameer Ajmani, rsc, iant, jnj, khr
Visibility:
Public.

Description

runtime: concurrent GC sweep Moves sweep phase out of stoptheworld by adding background sweeper goroutine and lazy on-demand sweeping. It turned out to be somewhat trickier than I expected, because there is no point in time when we know size of live heap nor consistent number of mallocs and frees. So everything related to next_gc, mprof, memstats, etc becomes trickier. At the end of GC next_gc is conservatively set to heap_alloc*GOGC, which is much larger than real value. But after every sweep next_gc is decremented by freed*GOGC. So when everything is swept next_gc becomes what it should be. For mprof I had to introduce 3-generation scheme (allocs, revent_allocs, prev_allocs), because by the end of GC we know number of frees for the *previous* GC. Significant caution is required to not cross yet-unknown real value of next_gc. This is achieved by 2 means: 1. Whenever I allocate a span from MCentral, I sweep a span in that MCentral. 2. Whenever I allocate N pages from MHeap, I sweep until at least N pages are returned to heap. This provides quite strong guarantees that heap does not grow when it should now. http-1 allocated 7036 7033 -0.04% allocs 60 60 +0.00% cputime 51050 46700 -8.52% gc-pause-one 34060569 1777993 -94.78% gc-pause-total 2554 133 -94.79% latency-50 178448 170926 -4.22% latency-95 284350 198294 -30.26% latency-99 345191 220652 -36.08% rss 101564416 101007360 -0.55% sys-gc 6606832 6541296 -0.99% sys-heap 88801280 87752704 -1.18% sys-other 7334208 7405928 +0.98% sys-stack 524288 524288 +0.00% sys-total 103266608 102224216 -1.01% time 50339 46533 -7.56% virtual-mem 292990976 293728256 +0.25% garbage-1 allocated 2983818 2990889 +0.24% allocs 62880 62902 +0.03% cputime 16480000 16190000 -1.76% gc-pause-one 828462467 487875135 -41.11% gc-pause-total 4142312 2439375 -41.11% rss 1151709184 1153712128 +0.17% sys-gc 66068352 66068352 +0.00% sys-heap 1039728640 1039728640 +0.00% sys-other 37776064 40770176 +7.93% sys-stack 8781824 8781824 +0.00% sys-total 1152354880 1155348992 +0.26% time 16496998 16199876 -1.80% virtual-mem 1409564672 1402281984 -0.52%

Patch Set 1 #

Patch Set 2 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 3 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 4 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 5 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 6 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 7 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 8 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 9 : diff -r b3caf13d930b https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 10 : diff -r 5330d59be152 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 11 : diff -r 88ac7297d2fa https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 12 : diff -r 88ac7297d2fa https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 13 : diff -r 88ac7297d2fa https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 14 : diff -r 88ac7297d2fa https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 15 : diff -r 88ac7297d2fa https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 16 : diff -r 88ac7297d2fa https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 6

Patch Set 17 : diff -r 50235ae4e784 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 18 : diff -r 50235ae4e784 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 19 : diff -r 50235ae4e784 https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 4

Patch Set 20 : diff -r 75adcf310434 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 21 : diff -r 75adcf310434 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 22 : diff -r 75adcf310434 https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 4

Patch Set 23 : diff -r 08918ee18957 https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 12

Patch Set 24 : diff -r daaac74e31ed https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 8

Patch Set 25 : diff -r 4106a965e536 https://dvyukov%40google.com@code.google.com/p/go/ #

Total comments: 4

Patch Set 26 : diff -r d2cd0d13a008 https://dvyukov%40google.com@code.google.com/p/go/ #

Patch Set 27 : diff -r d2cd0d13a008 https://dvyukov%40google.com@code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+499 lines, -127 lines) Patch
M src/pkg/runtime/malloc.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 9 chunks +21 lines, -6 lines 0 comments Download
M src/pkg/runtime/malloc.goc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +4 lines, -0 lines 0 comments Download
M src/pkg/runtime/mcentral.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 4 chunks +64 lines, -20 lines 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 23 chunks +238 lines, -79 lines 0 comments Download
M src/pkg/runtime/mheap.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 19 chunks +133 lines, -14 lines 0 comments Download
M src/pkg/runtime/mprof.goc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 chunks +39 lines, -8 lines 0 comments Download

Messages

Total messages: 28
dvyukov
Hello golang-codereviews@googlegroups.com (cc: cshapiro@golang.org, khr@golang.org, rsc@golang.org), I'd like you to review this change to https://dvyukov%40google.com@code.google.com/p/go/
10 years, 3 months ago (2014-01-02 15:49:24 UTC) #1
dvyukov
This turned out to be somewhat trickier than I expected due to various stats collection ...
10 years, 3 months ago (2014-01-02 15:52:20 UTC) #2
Sameer Ajmani
https://codereview.appspot.com/46430043/diff/230008/src/pkg/runtime/malloc.goc File src/pkg/runtime/malloc.goc (right): https://codereview.appspot.com/46430043/diff/230008/src/pkg/runtime/malloc.goc#newcode196 src/pkg/runtime/malloc.goc:196: else while(runtime·atomicload(&s->sweepgen) != sg) is it possible for s->sweepgen ...
10 years, 3 months ago (2014-01-03 17:19:38 UTC) #3
dvyukov
Thanks for looking https://codereview.appspot.com/46430043/diff/230008/src/pkg/runtime/malloc.goc File src/pkg/runtime/malloc.goc (right): https://codereview.appspot.com/46430043/diff/230008/src/pkg/runtime/malloc.goc#newcode196 src/pkg/runtime/malloc.goc:196: else while(runtime·atomicload(&s->sweepgen) != sg) On 2014/01/03 ...
10 years, 3 months ago (2014-01-03 17:49:56 UTC) #4
dvyukov
I've merged with new finalizers/specials, and the deadlock has gone away. all.bash now passes. Please ...
10 years, 3 months ago (2014-01-22 16:29:44 UTC) #5
dvyukov
On 2014/01/22 16:29:44, dvyukov wrote: > I've merged with new finalizers/specials, and the deadlock has ...
10 years, 3 months ago (2014-01-22 16:36:35 UTC) #6
rsc
This is pretty complex and there are no comments explaining the big picture. Could you ...
10 years, 3 months ago (2014-01-22 19:11:05 UTC) #7
dvyukov
PTAL I've added comments in mgc0.c and mprof.goc https://codereview.appspot.com/46430043/diff/330001/src/pkg/runtime/mcentral.c File src/pkg/runtime/mcentral.c (right): https://codereview.appspot.com/46430043/diff/330001/src/pkg/runtime/mcentral.c#newcode192 src/pkg/runtime/mcentral.c:192: } ...
10 years, 2 months ago (2014-01-23 18:29:47 UTC) #8
iant
https://codereview.appspot.com/46430043/diff/390001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/46430043/diff/390001/src/pkg/runtime/mgc0.c#newcode16 src/pkg/runtime/mgc0.c:16: // The sweep phase used to be stop-the-world as ...
10 years, 2 months ago (2014-01-28 23:41:11 UTC) #9
dvyukov
PTAL https://codereview.appspot.com/46430043/diff/390001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/46430043/diff/390001/src/pkg/runtime/mgc0.c#newcode16 src/pkg/runtime/mgc0.c:16: // The sweep phase used to be stop-the-world ...
10 years, 2 months ago (2014-01-29 13:20:49 UTC) #10
jnj
I have some grammar and spelling suggestions, if you like. https://codereview.appspot.com/46430043/diff/410001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/46430043/diff/410001/src/pkg/runtime/mgc0.c#newcode33 ...
10 years, 2 months ago (2014-01-29 17:56:05 UTC) #11
dvyukov
Thanks! https://codereview.appspot.com/46430043/diff/410001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/46430043/diff/410001/src/pkg/runtime/mgc0.c#newcode33 src/pkg/runtime/mgc0.c:33: // closer to the target value. However, this ...
10 years, 2 months ago (2014-01-30 09:44:40 UTC) #12
dvyukov
Thanks!
10 years, 2 months ago (2014-01-30 09:44:43 UTC) #13
jnj
https://codereview.appspot.com/46430043/diff/430001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/46430043/diff/430001/src/pkg/runtime/mgc0.c#newcode27 src/pkg/runtime/mgc0.c:27: // However, at the end of stop-the-world GC phase ...
10 years, 2 months ago (2014-01-30 18:03:35 UTC) #14
dvyukov
https://codereview.appspot.com/46430043/diff/430001/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/46430043/diff/430001/src/pkg/runtime/mgc0.c#newcode27 src/pkg/runtime/mgc0.c:27: // However, at the end of stop-the-world GC phase ...
10 years, 2 months ago (2014-02-03 08:10:22 UTC) #15
gobot
R=rsc@golang.org (assigned by dvyukov@google.com)
10 years, 2 months ago (2014-02-10 16:29:06 UTC) #16
rsc
LGTM Thanks for the comments. https://codereview.appspot.com/46430043/diff/450001/src/pkg/runtime/mcentral.c File src/pkg/runtime/mcentral.c (right): https://codereview.appspot.com/46430043/diff/450001/src/pkg/runtime/mcentral.c#newcode56 src/pkg/runtime/mcentral.c:56: // the span is ...
10 years, 2 months ago (2014-02-12 17:42:57 UTC) #17
dvyukov
fingers crossed https://codereview.appspot.com/46430043/diff/450001/src/pkg/runtime/mcentral.c File src/pkg/runtime/mcentral.c (right): https://codereview.appspot.com/46430043/diff/450001/src/pkg/runtime/mcentral.c#newcode56 src/pkg/runtime/mcentral.c:56: // the span is being sweept by ...
10 years, 2 months ago (2014-02-12 18:10:10 UTC) #18
dvyukov
*** Submitted as https://code.google.com/p/go/source/detail?r=e1d8f233470b *** runtime: concurrent GC sweep Moves sweep phase out of stoptheworld ...
10 years, 2 months ago (2014-02-12 18:17:50 UTC) #19
gobot
This CL appears to have broken the linux-amd64-race builder.
10 years, 2 months ago (2014-02-12 23:54:26 UTC) #20
gobot
This CL appears to have broken the linux-amd64-race builder.
10 years, 2 months ago (2014-02-12 23:54:33 UTC) #21
gobot
This CL appears to have broken the linux-amd64-race builder.
10 years, 2 months ago (2014-02-12 23:54:33 UTC) #22
minux1
bisect shows this CL is causing random nil pointer faults on dragonfly BSD amd64.
10 years, 1 month ago (2014-02-23 05:01:12 UTC) #23
dvyukov
On 2014/02/23 05:01:12, minux wrote: > bisect shows this CL is causing random nil pointer ...
10 years, 1 month ago (2014-02-23 09:45:38 UTC) #24
remyoudompheng
On 2014/02/23 09:45:38, dvyukov wrote: > On 2014/02/23 05:01:12, minux wrote: > > bisect shows ...
10 years, 1 month ago (2014-02-23 20:31:17 UTC) #25
minux1
On Sun, Feb 23, 2014 at 4:45 AM, <dvyukov@google.com> wrote: > On 2014/02/23 05:01:12, minux ...
10 years, 1 month ago (2014-02-23 21:26:52 UTC) #26
dvyukov
On Mon, Feb 24, 2014 at 12:31 AM, <remyoudompheng@gmail.com> wrote: > On 2014/02/23 09:45:38, dvyukov ...
10 years, 1 month ago (2014-02-24 08:02:13 UTC) #27
aram
10 years, 1 month ago (2014-03-11 16:59:36 UTC) #28
Message was sent while issue was closed.
This broke Solaris runtime tests:
https://code.google.com/p/go/issues/detail?id=7511
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b