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

Issue 7307086: code review 7307086: runtime: precise garbage collection of channels (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 2 months ago by atom
Modified:
11 years, 2 months ago
Reviewers:
CC:
dvyukov, rsc, bradfitz, dave_cheney.net, golang-dev, minux1, remyoudompheng
Visibility:
Public.

Description

runtime: precise garbage collection of channels This changeset adds a mostly-precise garbage collection of channels. The garbage collection support code in the linker isn't recognizing channel types yet. Fixes issue http://stackoverflow.com/questions/14712586/memory-consumption-skyrocket

Patch Set 1 #

Total comments: 8

Patch Set 2 : diff -r bd83fa6162f2 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 3 : diff -r bd83fa6162f2 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+34 lines, -0 lines) Patch
M src/pkg/runtime/chan.c View 1 2 3 chunks +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/malloc.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 6 chunks +27 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 38
atom
Hello golang-dev@googlegroups.com (cc: rsc, dfc, dvyukov, minux, remyoudompheng), I'd like you to review this change ...
11 years, 2 months ago (2013-02-10 11:01:33 UTC) #1
dvyukov
https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/chan.c File src/pkg/runtime/chan.c (right): https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/chan.c#newcode117 src/pkg/runtime/chan.c:117: runtime·settype(c, (uintptr)t | TypeInfo_Chan); the Hchan itself does not ...
11 years, 2 months ago (2013-02-10 11:14:57 UTC) #2
atom
https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/chan.c File src/pkg/runtime/chan.c (right): https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/chan.c#newcode117 src/pkg/runtime/chan.c:117: runtime·settype(c, (uintptr)t | TypeInfo_Chan); On 2013/02/10 11:14:58, dvyukov wrote: ...
11 years, 2 months ago (2013-02-10 14:20:28 UTC) #3
rsc
https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/mgc0.c#newcode914 src/pkg/runtime/mgc0.c:914: *objbufpos++ = (Obj){(byte*)chan, Hchansize, (uintptr)defaultProg}; Is there a noPointersProg ...
11 years, 2 months ago (2013-02-14 21:46:49 UTC) #4
atom
https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/mgc0.c File src/pkg/runtime/mgc0.c (right): https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/mgc0.c#newcode914 src/pkg/runtime/mgc0.c:914: *objbufpos++ = (Obj){(byte*)chan, Hchansize, (uintptr)defaultProg}; On 2013/02/14 21:46:49, rsc ...
11 years, 2 months ago (2013-02-15 09:40:53 UTC) #5
rsc
On Fri, Feb 15, 2013 at 4:40 AM, <0xE2.0x9A.0x9B@gmail.com> wrote: > > https://codereview.appspot.**com/7307086/diff/1/src/pkg/**runtime/mgc0.c<https://codereview.appspot.com/7307086/diff/1/src/pkg/runtime/mgc0.c> > File ...
11 years, 2 months ago (2013-02-19 18:29:13 UTC) #6
atom
Hello dvyukov@google.com, rsc@golang.org (cc: dave@cheney.net, golang-dev@googlegroups.com, minux.ma@gmail.com, remyoudompheng@gmail.com), Please take another look.
11 years, 2 months ago (2013-02-19 19:15:04 UTC) #7
atom
On 2013/02/19 18:29:13, rsc wrote: > On Fri, Feb 15, 2013 at 4:40 AM, <mailto:0xE2.0x9A.0x9B@gmail.com> ...
11 years, 2 months ago (2013-02-19 19:16:22 UTC) #8
rsc
LGTM https://codereview.appspot.com/7307086/diff/10001/src/pkg/runtime/runtime.h File src/pkg/runtime/runtime.h (right): https://codereview.appspot.com/7307086/diff/10001/src/pkg/runtime/runtime.h#newcode593 src/pkg/runtime/runtime.h:593: extern uint32 Hchansize; This needs to be runtime.Hchansize, ...
11 years, 2 months ago (2013-02-19 19:29:03 UTC) #9
atom
Hello dvyukov@google.com, rsc@golang.org (cc: dave@cheney.net, golang-dev@googlegroups.com, minux.ma@gmail.com, remyoudompheng@gmail.com), Please take another look.
11 years, 2 months ago (2013-02-19 19:35:39 UTC) #10
atom
https://codereview.appspot.com/7307086/diff/10001/src/pkg/runtime/runtime.h File src/pkg/runtime/runtime.h (right): https://codereview.appspot.com/7307086/diff/10001/src/pkg/runtime/runtime.h#newcode593 src/pkg/runtime/runtime.h:593: extern uint32 Hchansize; On 2013/02/19 19:29:03, rsc wrote: > ...
11 years, 2 months ago (2013-02-19 20:02:39 UTC) #11
rsc
I patched this into my client in preparation for submitting it, but all.bash failed. On ...
11 years, 2 months ago (2013-02-19 20:29:49 UTC) #12
rsc
Forgot to say I am using darwin/amd64 on OS X 10.8.2. Russ
11 years, 2 months ago (2013-02-19 20:41:05 UTC) #13
atom
On 2013/02/19 20:29:49, rsc wrote: > I patched this into my client in preparation for ...
11 years, 2 months ago (2013-02-19 21:05:55 UTC) #14
bradfitz
On Tue, Feb 19, 2013 at 1:05 PM, <0xE2.0x9A.0x9B@gmail.com> wrote: > Cannot test package "net" ...
11 years, 2 months ago (2013-02-19 21:07:54 UTC) #15
atom
On 2013/02/19 21:07:54, bradfitz wrote: > On Tue, Feb 19, 2013 at 1:05 PM, <mailto:0xE2.0x9A.0x9B@gmail.com> ...
11 years, 2 months ago (2013-02-19 21:15:32 UTC) #16
bradfitz
On Tue, Feb 19, 2013 at 1:15 PM, <0xE2.0x9A.0x9B@gmail.com> wrote: > On 2013/02/19 21:07:54, bradfitz ...
11 years, 2 months ago (2013-02-19 21:26:15 UTC) #17
atom
On 2013/02/19 21:26:15, bradfitz wrote: > On Tue, Feb 19, 2013 at 1:15 PM, <mailto:0xE2.0x9A.0x9B@gmail.com> ...
11 years, 2 months ago (2013-02-19 21:33:48 UTC) #18
bradfitz
On Tue, Feb 19, 2013 at 1:33 PM, <0xE2.0x9A.0x9B@gmail.com> wrote: > > > Cannot test ...
11 years, 2 months ago (2013-02-19 22:10:47 UTC) #19
atom
On 2013/02/19 22:10:47, bradfitz wrote: > On Tue, Feb 19, 2013 at 1:33 PM, <mailto:0xE2.0x9A.0x9B@gmail.com> ...
11 years, 2 months ago (2013-02-19 22:31:23 UTC) #20
atom
On 2013/02/19 21:33:48, atom wrote: > On 2013/02/19 21:26:15, bradfitz wrote: > > On Tue, ...
11 years, 2 months ago (2013-02-20 10:46:04 UTC) #21
atom
On 2013/02/19 20:29:49, rsc wrote: > I patched this into my client in preparation for ...
11 years, 2 months ago (2013-02-20 10:54:08 UTC) #22
bradfitz
On Wed, Feb 20, 2013 at 2:46 AM, <0xE2.0x9A.0x9B@gmail.com> wrote: > On 2013/02/19 21:33:48, atom ...
11 years, 2 months ago (2013-02-20 15:20:20 UTC) #23
atom
On 2013/02/19 20:29:49, rsc wrote: > I patched this into my client in preparation for ...
11 years, 2 months ago (2013-02-22 16:37:23 UTC) #24
rsc
Yes. I always run with GOMAXPROCS unset, so it should be 1 already. Sorry I ...
11 years, 2 months ago (2013-02-22 16:51:56 UTC) #25
atom
On 2013/02/22 16:51:56, rsc wrote: > Yes. I always run with GOMAXPROCS unset, so it ...
11 years, 2 months ago (2013-02-22 17:13:24 UTC) #26
dvyukov
On Fri, Feb 22, 2013 at 9:13 PM, <0xE2.0x9A.0x9B@gmail.com> wrote: > On 2013/02/22 16:51:56, rsc ...
11 years, 2 months ago (2013-02-22 17:17:31 UTC) #27
atom
On 2013/02/22 17:17:31, dvyukov wrote: > On Fri, Feb 22, 2013 at 9:13 PM, <mailto:0xE2.0x9A.0x9B@gmail.com> ...
11 years, 2 months ago (2013-02-22 17:30:33 UTC) #28
atom
On 2013/02/22 17:30:33, atom wrote: > On 2013/02/22 17:17:31, dvyukov wrote: > > On Fri, ...
11 years, 2 months ago (2013-02-22 18:12:55 UTC) #29
rsc
On Fri, Feb 22, 2013 at 12:13 PM, <0xE2.0x9A.0x9B@gmail.com> wrote: > The net package is ...
11 years, 2 months ago (2013-02-22 18:23:23 UTC) #30
0xe2.0x9a.0x9b_gmail.com
On Fri, Feb 22, 2013 at 7:23 PM, Russ Cox <rsc@golang.org> wrote: > On Fri, ...
11 years, 2 months ago (2013-02-22 19:20:02 UTC) #31
rsc
Update: I fixed the bug we hit a few weeks ago (issue 4907) but that ...
11 years, 2 months ago (2013-02-25 17:18:11 UTC) #32
rsc
The tree with this CL patched in did not crash reliably for me on Linux, ...
11 years, 2 months ago (2013-02-25 18:36:46 UTC) #33
atom
With and also without CL 7364048 I am getting SIGSEGV in gdb on linux/386. $ ...
11 years, 2 months ago (2013-02-25 19:32:19 UTC) #34
rsc
Found it. The block size known to the garbage collector may be larger than the ...
11 years, 2 months ago (2013-02-25 20:54:32 UTC) #35
rsc
all.bash is happy now. Submitting, and on to the next bug.
11 years, 2 months ago (2013-02-25 20:57:58 UTC) #36
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=1c50db40d078 *** runtime: precise garbage collection of channels This changeset adds a ...
11 years, 2 months ago (2013-02-25 20:58:26 UTC) #37
atom
11 years, 2 months ago (2013-02-25 21:14:35 UTC) #38
On 2013/02/25 20:54:32, rsc wrote:
> Found it. The block size known to the garbage collector may be larger than
> the block size requested by the allocation of the channel.

That is so obvious after giving a thought. Sorry for the inconvenience.

> For an
> unbuffered channel on amd64, it turns out to be 8 bytes larger. The buffer
> is assumed to be the rest of the block, but the element size may not neatly
> divide this leftover. Again on amd64, the problem happens with a chan of
> interface values and 8 bytes left over. The "second" word of the interface
> is really some other piece of memory, and if it is non-zero then the
> collector assumes the first word can be dereferenced using iface->tab->type.
> 
> I changed the GC_CHAN case to:
> 
> // There are no heap pointers in struct Hchan,
> // so we can ignore the leading sizeof(Hchan) bytes.
> if(!(chantype->elem->kind & KindNoPointers)) {
> // Channel's buffer follows Hchan immediately in memory.
> // Size of buffer (cap(c)) is second int in the chan struct.
> n = ((uintgo*)chan)[1];
> if(n > 0) {
> // TODO(atom): split into two chunks so that only the
> // in-use part of the circular buffer is scanned.
> // (Channel routines zero the unused part, so the current
> // code does not lead to leaks, it's just a little inefficient.)
> *objbufpos++ = (Obj){(byte*)chan+runtime·Hchansize, n*chantype->elem->size,
> (uintptr)chantype->elem->gc | PRECISE | LOOP};
> if(objbufpos == objbuf_end)
> flushobjbuf(objbuf, &objbufpos, &wp, &wbuf, &nobj);
> }
> }
> goto next_block;
> 
> (the difference is the computation of the size to use in the new (Obj)
> being queued), and now the net test is passing repeatedly.
> 
> Russ
Sign in to reply to this message.

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