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

Issue 14794043: code review 14794043: runtime: pass key/value to map accessors by reference, ... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 9 months ago by khr
Modified:
11 years, 7 months ago
Reviewers:
dave, rsc, dvyukov
CC:
golang-dev, dvyukov, khr1, rsc
Visibility:
Public.

Description

runtime: pass key/value to map accessors by reference, not by value. This change is part of the plan to get rid of all vararg C calls which are a pain for getting exact stack scanning. We allocate a chunk of zero memory to return a pointer to when a map access doesn't find the key. This is simpler than returning nil and fixing things up in the caller. Linker magic allocates a single zero memory area that is shared by all (non-reflect-generated) map types. Passing things by reference gets rid of some copies, so it speeds up code with big keys/values. benchmark old ns/op new ns/op delta BenchmarkBigKeyMap 34 31 -8.48% BenchmarkBigValMap 37 30 -18.62% BenchmarkSmallKeyMap 26 23 -11.28%

Patch Set 1 #

Patch Set 2 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 3 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 4 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 5 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 6 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 7 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 8 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 9 : diff -r f1545db4a9c4 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 10 : diff -r d809ded6f335 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 11 : diff -r d809ded6f335 https://khr%40golang.org@code.google.com/p/go/ #

Total comments: 2

Patch Set 12 : diff -r d809ded6f335 https://khr%40golang.org@code.google.com/p/go/ #

Total comments: 3

Patch Set 13 : diff -r d809ded6f335 https://khr%40golang.org@code.google.com/p/go/ #

Total comments: 1

Patch Set 14 : diff -r d809ded6f335 https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 15 : diff -r 7326da92ff4d https://khr%40golang.org@code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+391 lines, -282 lines) Patch
M src/cmd/gc/builtin.c View 1 2 3 4 5 6 7 8 1 chunk +4 lines, -6 lines 0 comments Download
M src/cmd/gc/fmt.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +4 lines, -0 lines 0 comments Download
M src/cmd/gc/go.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +2 lines, -0 lines 0 comments Download
M src/cmd/gc/range.c View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +13 lines, -15 lines 0 comments Download
M src/cmd/gc/reflect.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 chunks +103 lines, -10 lines 0 comments Download
M src/cmd/gc/runtime.go View 1 2 3 4 5 6 1 chunk +4 lines, -6 lines 0 comments Download
M src/cmd/gc/walk.c View 1 2 3 4 5 6 7 8 7 chunks +105 lines, -40 lines 0 comments Download
M src/pkg/reflect/type.go View 1 2 3 4 5 6 7 8 6 chunks +6 lines, -0 lines 0 comments Download
M src/pkg/reflect/value.go View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/hashmap.c View 1 2 3 4 5 6 7 8 9 10 11 14 chunks +113 lines, -188 lines 0 comments Download
M src/pkg/runtime/hashmap_fast.c View 1 2 3 4 5 6 7 8 5 chunks +4 lines, -9 lines 0 comments Download
M src/pkg/runtime/mapspeed_test.go View 1 2 3 4 5 6 7 8 1 chunk +30 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 6 7 8 9 1 chunk +0 lines, -6 lines 0 comments Download
M src/pkg/runtime/type.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/typekind.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 17
khr
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://khr%40golang.org@code.google.com/p/go/
11 years, 8 months ago (2013-11-13 00:43:25 UTC) #1
dvyukov
https://codereview.appspot.com/14794043/diff/206001/src/pkg/runtime/hashmap.c File src/pkg/runtime/hashmap.c (right): https://codereview.appspot.com/14794043/diff/206001/src/pkg/runtime/hashmap.c#newcode741 src/pkg/runtime/hashmap.c:741: uint8* value; // Must be in second position. please ...
11 years, 8 months ago (2013-11-14 05:52:43 UTC) #2
khr1
On Wed, Nov 13, 2013 at 9:52 PM, <dvyukov@google.com> wrote: > > https://codereview.appspot.com/14794043/diff/206001/src/ > pkg/runtime/hashmap.c ...
11 years, 8 months ago (2013-11-14 06:19:19 UTC) #3
dvyukov
On 2013/11/14 06:19:19, khr1 wrote: > On Wed, Nov 13, 2013 at 9:52 PM, <mailto:dvyukov@google.com> ...
11 years, 8 months ago (2013-11-14 06:37:20 UTC) #4
dvyukov
https://codereview.appspot.com/14794043/diff/226001/src/cmd/gc/range.c File src/cmd/gc/range.c (right): https://codereview.appspot.com/14794043/diff/226001/src/cmd/gc/range.c#newcode13 src/cmd/gc/range.c:13: Type *hiter(Type* t); move to go.h, there is a ...
11 years, 8 months ago (2013-11-14 06:57:39 UTC) #5
khr1
On Wed, Nov 13, 2013 at 10:57 PM, <dvyukov@google.com> wrote: > > https://codereview.appspot.com/14794043/diff/226001/src/cmd/gc/range.c > File ...
11 years, 8 months ago (2013-11-18 21:07:32 UTC) #6
rsc
Please arrange for the type to have a name (maybe map.iter), similar to what I ...
11 years, 8 months ago (2013-11-18 21:43:48 UTC) #7
dvyukov
LGTM
11 years, 8 months ago (2013-11-19 05:03:45 UTC) #8
rsc
https://codereview.appspot.com/14794043/diff/246001/src/pkg/runtime/type.h File src/pkg/runtime/type.h (right): https://codereview.appspot.com/14794043/diff/246001/src/pkg/runtime/type.h#newcode34 src/pkg/runtime/type.h:34: byte *zero; // ptr to the zero value for ...
11 years, 8 months ago (2013-11-19 14:28:04 UTC) #9
rsc
That is, the zero would be attached to the MapType and be a zero the ...
11 years, 8 months ago (2013-11-19 14:28:28 UTC) #10
khr1
I'd like to leave it there because I'm also going to be using the zero ...
11 years, 8 months ago (2013-11-19 16:54:15 UTC) #11
rsc
On Tue, Nov 19, 2013 at 11:54 AM, Keith Randall <khr@google.com> wrote: > I'd like ...
11 years, 8 months ago (2013-11-21 14:53:03 UTC) #12
khr1
Ok, PTAL. On Thu, Nov 21, 2013 at 6:53 AM, Russ Cox <rsc@golang.org> wrote: > ...
11 years, 8 months ago (2013-11-21 17:07:42 UTC) #13
rsc
LGTM
11 years, 8 months ago (2013-11-21 18:16:20 UTC) #14
khr
*** Submitted as https://code.google.com/p/go/source/detail?r=6e50725ac753 *** runtime: pass key/value to map accessors by reference, not by ...
11 years, 7 months ago (2013-12-02 21:05:07 UTC) #15
dave_cheney.net
On 2013/12/02 21:05:07, khr wrote: > *** Submitted as https://code.google.com/p/go/source/detail?r=6e50725ac753 *** > > runtime: pass ...
11 years, 7 months ago (2013-12-02 23:19:25 UTC) #16
khr1
11 years, 7 months ago (2013-12-02 23:30:44 UTC) #17
Bugs would be good.


On Mon, Dec 2, 2013 at 3:19 PM, <dave@cheney.net> wrote:

> On 2013/12/02 21:05:07, khr wrote:
>
>> *** Submitted as
>>
> https://code.google.com/p/go/source/detail?r=6e50725ac753 ***
>
>  runtime: pass key/value to map accessors by reference, not by value.
>>
>
>  This change is part of the plan to get rid of all vararg C calls
>> which are a pain for getting exact stack scanning.
>>
>
>  We allocate a chunk of zero memory to return a pointer to when a
>> map access doesn't find the key.  This is simpler than returning nil
>> and fixing things up in the caller.  Linker magic allocates a single
>> zero memory area that is shared by all (non-reflect-generated) map
>> types.
>>
>
>  Passing things by reference gets rid of some copies, so it speeds
>> up code with big keys/values.
>>
>
>  benchmark             old ns/op    new ns/op    delta
>> BenchmarkBigKeyMap           34           31   -8.48%
>> BenchmarkBigValMap           37           30  -18.62%
>> BenchmarkSmallKeyMap         26           23  -11.28%
>>
>
>  R=golang-dev, dvyukov, khr, rsc
>> CC=golang-dev
>> https://codereview.appspot.com/14794043
>>
>
> This commit generated two build failures. Do you want bugs created for
> them, or are you already on it ?
>
> https://codereview.appspot.com/14794043/
>
Sign in to reply to this message.

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