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

Issue 4811041: code review 4811041: runtime: tweak select performance (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 8 months ago by dvyukov
Modified:
13 years, 7 months ago
Reviewers:
albert.strasheim
CC:
rsc, ken2, golang-dev
Visibility:
Public.

Description

runtime: tweak select performance Make selectsend() accept pointer to the element, it makes it possible to make Scase fixed-size and allocate/free Select, all Scase's and all SudoG at once. As a consequence SudoG freelist die out. benchmark old,ns/op new,ns/op BenchmarkSelectUncontended 1080 558 BenchmarkSelectUncontended-2 675 264 BenchmarkSelectUncontended-4 459 205 BenchmarkSelectContended 1086 560 BenchmarkSelectContended-2 1775 1672 BenchmarkSelectContended-4 2668 2149 (on Intel Q6600, 4 cores, 2.4GHz) benchmark old ns/op new ns/op delta BenchmarkSelectUncontended 517.00 326.00 -36.94% BenchmarkSelectUncontended-2 281.00 166.00 -40.93% BenchmarkSelectUncontended-4 250.00 83.10 -66.76% BenchmarkSelectUncontended-8 107.00 47.40 -55.70% BenchmarkSelectUncontended-16 67.80 41.30 -39.09% BenchmarkSelectContended 513.00 325.00 -36.65% BenchmarkSelectContended-2 699.00 628.00 -10.16% BenchmarkSelectContended-4 1085.00 1092.00 +0.65% BenchmarkSelectContended-8 3253.00 2477.00 -23.85% BenchmarkSelectContended-16 5313.00 5116.00 -3.71% (on Intel E5620, 8 HT cores, 2.4 GHz)

Patch Set 1 #

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

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

Patch Set 4 : diff -r 122ea252305f https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 122ea252305f https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r 122ea252305f https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r 122ea252305f https://go.googlecode.com/hg/ #

Patch Set 8 : diff -r 122ea252305f https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 9 : diff -r a4c2e46af9b2 https://go.googlecode.com/hg/ #

Patch Set 10 : diff -r a4c2e46af9b2 https://go.googlecode.com/hg/ #

Patch Set 11 : diff -r a4c2e46af9b2 https://go.googlecode.com/hg/ #

Patch Set 12 : diff -r 18d4de4963b7 https://go.googlecode.com/hg/ #

Patch Set 13 : diff -r 18d4de4963b7 https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 14 : diff -r 18d4de4963b7 https://go.googlecode.com/hg/ #

Patch Set 15 : diff -r 18d4de4963b7 https://go.googlecode.com/hg/ #

Patch Set 16 : diff -r 18d4de4963b7 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+124 lines, -162 lines) Patch
M src/cmd/gc/builtin.c.boot View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/gc/go.h View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/gc/runtime.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/gc/select.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +6 lines, -1 line 0 comments Download
M src/cmd/gc/subr.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +28 lines, -9 lines 0 comments Download
M src/cmd/ld/dwarf.c View 1 2 3 4 1 chunk +0 lines, -1 line 0 comments Download
M src/pkg/runtime/chan.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 30 chunks +87 lines, -149 lines 0 comments Download

Messages

Total messages: 20
dvyukov
Hello rsc@golang.org, ken@golang.org, golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 8 months ago (2011-07-20 17:32:48 UTC) #1
rsc
http://codereview.appspot.com/4811041/diff/3005/src/cmd/gc/select.c File src/cmd/gc/select.c (right): http://codereview.appspot.com/4811041/diff/3005/src/cmd/gc/select.c#newcode316 src/cmd/gc/select.c:316: if(n->right->op != ONAME || This test is wrong. You ...
13 years, 8 months ago (2011-07-20 18:05:32 UTC) #2
dvyukov
> http://codereview.appspot.com/4811041/diff/3005/src/pkg/runtime/chan.c#newcode73 > src/pkg/runtime/chan.c:73: Scase* scase[1]; // one per case > If you change this ...
13 years, 8 months ago (2011-07-20 18:57:52 UTC) #3
rsc
> It's what I've done first. However, then I realized that we need 3 > ...
13 years, 8 months ago (2011-07-20 19:01:13 UTC) #4
dvyukov
> http://codereview.appspot.com/4811041/diff/3005/src/pkg/runtime/chan.c#newcode636 > src/pkg/runtime/chan.c:636: runtime·selectsend(Select *sel, Hchan *c, ...) > Since you changed this to ...
13 years, 8 months ago (2011-07-20 19:09:02 UTC) #5
rsc
>> runtime.selectsend(Select *sel, Hchan *c, void *elem) > > Humm... selectsend become exactly as selectrecv, ...
13 years, 8 months ago (2011-07-20 19:13:00 UTC) #6
dvyukov
On 2011/07/20 18:05:32, rsc wrote: > http://codereview.appspot.com/4811041/diff/3005/src/cmd/gc/select.c > File src/cmd/gc/select.c (right): > > http://codereview.appspot.com/4811041/diff/3005/src/cmd/gc/select.c#newcode316 > ...
13 years, 8 months ago (2011-07-20 19:31:19 UTC) #7
dvyukov
Hello rsc@golang.org, ken@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 8 months ago (2011-07-21 14:50:26 UTC) #8
rsc
very nice http://codereview.appspot.com/4811041/diff/22001/src/cmd/gc/select.c File src/cmd/gc/select.c (right): http://codereview.appspot.com/4811041/diff/22001/src/cmd/gc/select.c#newcode313 src/cmd/gc/select.c:313: n->left = localexpr(n->left, &r->ninit); you don't need ...
13 years, 8 months ago (2011-07-21 15:42:48 UTC) #9
dvyukov
Hello rsc@golang.org, ken@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 8 months ago (2011-07-21 16:35:49 UTC) #10
dvyukov
On 2011/07/21 15:42:48, rsc wrote: > very nice > > http://codereview.appspot.com/4811041/diff/22001/src/cmd/gc/select.c > File src/cmd/gc/select.c (right): ...
13 years, 8 months ago (2011-07-21 16:36:10 UTC) #11
rsc
> Hummm.... I think your code can sigsegv on nil channel... my code is identical ...
13 years, 8 months ago (2011-07-21 16:58:15 UTC) #12
dvyukov
On 2011/07/21 16:58:15, rsc wrote: > > Hummm.... I think your code can sigsegv on ...
13 years, 8 months ago (2011-07-21 17:13:35 UTC) #13
rsc
> It's quite tricky and implicit. Perhaps it's better to add explicit > check for ...
13 years, 8 months ago (2011-07-21 17:22:16 UTC) #14
dvyukov
Hello rsc@golang.org, ken@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 8 months ago (2011-07-21 17:31:48 UTC) #15
rsc
LGTM
13 years, 8 months ago (2011-07-21 17:49:54 UTC) #16
rsc
*** Submitted as http://code.google.com/p/go/source/detail?r=2ccdb29d715c *** runtime: faster select Make selectsend() accept pointer to the element, ...
13 years, 8 months ago (2011-07-21 17:57:18 UTC) #17
albert.strasheim
Hello all On 2011/07/21 17:57:18, rsc wrote: > *** Submitted as http://code.google.com/p/go/source/detail?r=2ccdb29d715c *** > runtime: ...
13 years, 8 months ago (2011-07-25 15:11:54 UTC) #18
rsc
will fix
13 years, 8 months ago (2011-07-25 15:25:24 UTC) #19
dvyukov
13 years, 8 months ago (2011-07-25 15:43:10 UTC) #20
On 2011/07/25 15:11:54, albert.strasheim wrote:
> Hello all
> 
> On 2011/07/21 17:57:18, rsc wrote:
> > *** Submitted as http://code.google.com/p/go/source/detail?r=2ccdb29d715c
***
> > runtime: faster select
> > Make selectsend() accept pointer to the element,
> > it makes it possible to make Scase fixed-size
> > and allocate/free Select, all Scase's and all SudoG at once.
> > As a consequence SudoG freelist die out.
> 
> This change seems to have broken some of our internal code.
> 
> Bug report here:
> 
> http://code.google.com/p/go/issues/detail?id=2102
> 
> Regards
> 
> Albert

Hi Albert,

Sorry for this. Please, try this patch:
hg clpatch 4825043

http://codereview.appspot.com/4825043/
Sign in to reply to this message.

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