runtime: get rid of the settype buffer and lock.
MCaches now hold a MSpan for each sizeclass which they have
exclusive access to allocate from, so no lock is needed.
Modifying the heap bitmaps also no longer requires a cas.
runtime.free gets more expensive. But we don't use it
much any more.
It's not much faster on 1 processor, but it's a lot
faster on multiple processors.
benchmark old ns/op new ns/op delta
BenchmarkSetTypeNoPtr1 24 23 -0.42%
BenchmarkSetTypeNoPtr2 33 34 +0.89%
BenchmarkSetTypePtr1 51 49 -3.72%
BenchmarkSetTypePtr2 55 54 -1.98%
benchmark old ns/op new ns/op delta
BenchmarkAllocation 52739 50770 -3.73%
BenchmarkAllocation-2 33957 34141 +0.54%
BenchmarkAllocation-3 33326 29015 -12.94%
BenchmarkAllocation-4 38105 25795 -32.31%
BenchmarkAllocation-5 68055 24409 -64.13%
BenchmarkAllocation-6 71544 23488 -67.17%
BenchmarkAllocation-7 68374 23041 -66.30%
BenchmarkAllocation-8 70117 20758 -70.40%
Hello dvyukov@google.com (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://khr%40golang.org@code.google.com/p/go/
12 years, 10 months ago
(2014-01-25 00:17:07 UTC)
#1
please wait for https://codereview.appspot.com/46430043/ otherwise I will never submit it https://codereview.appspot.com/46810043/diff/230001/src/pkg/runtime/gc_test.go File src/pkg/runtime/gc_test.go (right): https://codereview.appspot.com/46810043/diff/230001/src/pkg/runtime/gc_test.go#newcode155 ...
12 years, 10 months ago
(2014-01-27 12:48:09 UTC)
#4
On 2014/01/27 19:21:18, khr1 wrote: > On Mon, Jan 27, 2014 at 5:48 AM, <mailto:dvyukov@google.com> ...
12 years, 10 months ago
(2014-01-28 02:20:20 UTC)
#9
On 2014/01/27 19:21:18, khr1 wrote:
> On Mon, Jan 27, 2014 at 5:48 AM, <mailto:dvyukov@google.com> wrote:
>
> > move MCaches to next line in change description -- first line is summary
> >
> >
> Fixed.
>
>
> > https://codereview.appspot.com/46810043/
> >
Huh, replies from my google email don't tell the dev dashboard that I've
replied. I need to use the web with my khr@golang.org account.
https://codereview.appspot.com/46810043/diff/390001/src/pkg/runtime/mcentral.c File src/pkg/runtime/mcentral.c (right): https://codereview.appspot.com/46810043/diff/390001/src/pkg/runtime/mcentral.c#newcode123 src/pkg/runtime/mcentral.c:123: MCentral_ReturnToHeap(c, s); say that it unlocks c
12 years, 9 months ago
(2014-02-16 08:52:16 UTC)
#12
please also test with: go test -race -short -cpu=4 std that's what i frequently forget ...
12 years, 9 months ago
(2014-02-26 07:21:48 UTC)
#15
please also test with:
go test -race -short -cpu=4 std
that's what i frequently forget to do myself, but it frequently uncovers bugs
because of different timings
On 2014/02/26 07:20:51, dvyukov wrote: > LGTM > > i need to say that the ...
12 years, 9 months ago
(2014-02-26 23:49:17 UTC)
#16
On 2014/02/26 07:20:51, dvyukov wrote:
> LGTM
>
> i need to say that the code is more complex than I would like it to be,
because
> of the concurrent sweep
>
> https://codereview.appspot.com/46810043/diff/430001/src/pkg/runtime/mcentral.c
> File src/pkg/runtime/mcentral.c (right):
>
>
https://codereview.appspot.com/46810043/diff/430001/src/pkg/runtime/mcentral....
> src/pkg/runtime/mcentral.c:167: runtime·MSpan_EnsureSwept(s);
> I do not see how s can be unswept here.
> We ensure that it is swept in free, then (1) if MCentral_Free is called before
> GC the span is still swept, or (2) GC flushes all caches. So it must be always
> swept here.
> If you agree, please change it to if/throw. It's important to understand the
> invariants here because of the complexity.
Changed, and it never triggers.
> https://codereview.appspot.com/46810043/diff/430001/src/pkg/runtime/mgc0.c
> File src/pkg/runtime/mgc0.c (right):
>
>
https://codereview.appspot.com/46810043/diff/430001/src/pkg/runtime/mgc0.c#ne...
> src/pkg/runtime/mgc0.c:1868: if(!sweepgenset && nfree == 0) {
> please add a comment somewhere here along the lines:
>
> we need to set s->sweepgen = h->sweepgen only when all blocks are swept,
because
> of potential concurrent free/SetFinalizer
> but we need to set it before we make the span available for allocation (return
> it to heap or mcentral), because allocation code assumes that a span is
already
> swept if available for allocation
>
Done.
>
https://codereview.appspot.com/46810043/diff/430001/src/pkg/runtime/mgc0.c#ne...
> src/pkg/runtime/mgc0.c:1952: if(s->incache) {
> drop {}
Done.
On 2014/02/26 07:21:48, dvyukov wrote: > please also test with: > go test -race -short ...
12 years, 9 months ago
(2014-02-26 23:50:21 UTC)
#17
On 2014/02/26 07:21:48, dvyukov wrote:
> please also test with:
> go test -race -short -cpu=4 std
> that's what i frequently forget to do myself, but it frequently uncovers bugs
> because of different timings
It seems induce no new errors that are not already present at tip...
*** Submitted as https://code.google.com/p/go/source/detail?r=13f8dc6e750f *** runtime: get rid of the settype buffer and lock. MCaches ...
12 years, 9 months ago
(2014-02-26 23:53:02 UTC)
#18
*** Submitted as https://code.google.com/p/go/source/detail?r=13f8dc6e750f ***
runtime: get rid of the settype buffer and lock.
MCaches now hold a MSpan for each sizeclass which they have
exclusive access to allocate from, so no lock is needed.
Modifying the heap bitmaps also no longer requires a cas.
runtime.free gets more expensive. But we don't use it
much any more.
It's not much faster on 1 processor, but it's a lot
faster on multiple processors.
benchmark old ns/op new ns/op delta
BenchmarkSetTypeNoPtr1 24 23 -0.42%
BenchmarkSetTypeNoPtr2 33 34 +0.89%
BenchmarkSetTypePtr1 51 49 -3.72%
BenchmarkSetTypePtr2 55 54 -1.98%
benchmark old ns/op new ns/op delta
BenchmarkAllocation 52739 50770 -3.73%
BenchmarkAllocation-2 33957 34141 +0.54%
BenchmarkAllocation-3 33326 29015 -12.94%
BenchmarkAllocation-4 38105 25795 -32.31%
BenchmarkAllocation-5 68055 24409 -64.13%
BenchmarkAllocation-6 71544 23488 -67.17%
BenchmarkAllocation-7 68374 23041 -66.30%
BenchmarkAllocation-8 70117 20758 -70.40%
LGTM=rsc, dvyukov
R=dvyukov, bradfitz, khr, rsc
CC=golang-codereviews
https://codereview.appspot.com/46810043
Issue 46810043: code review 46810043: runtime: get rid of the settype buffer and lock. MCaches
(Closed)
Created 12 years, 11 months ago by khr
Modified 12 years, 9 months ago
Reviewers: gobot
Base URL:
Comments: 11