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

Issue 120140044: code review 120140044: sync/atomic: add Value (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 9 months ago by dvyukov
Modified:
9 years, 7 months ago
Reviewers:
r, ruiu, minux, rsc, josharian
CC:
golang-codereviews, dave_cheney.net
Visibility:
Public.

Description

sync/atomic: add Value A Value provides an atomic load and store of a consistently typed value. It's intended to be used with copy-on-write idiom (see the example). Performance: BenchmarkValueRead 50000000 21.7 ns/op BenchmarkValueRead-2 200000000 8.63 ns/op BenchmarkValueRead-4 300000000 4.33 ns/op

Patch Set 1 #

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

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

Total comments: 2

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

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

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

Total comments: 1

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

Total comments: 6

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

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

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

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

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

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

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

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

Total comments: 9

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

Total comments: 4

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

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

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+319 lines, -0 lines) Patch
M src/pkg/runtime/thunk.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +6 lines, -0 lines 0 comments Download
A src/pkg/sync/atomic/norace.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +17 lines, -0 lines 0 comments Download
M src/pkg/sync/atomic/race.go View 1 2 3 4 5 6 7 8 9 1 chunk +10 lines, -0 lines 0 comments Download
A src/pkg/sync/atomic/value.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +91 lines, -0 lines 0 comments Download
A src/pkg/sync/atomic/value_test.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +195 lines, -0 lines 0 comments Download

Messages

Total messages: 42
rsc
https://codereview.appspot.com/120140044/diff/40001/src/pkg/sync/atomic/value_test.go File src/pkg/sync/atomic/value_test.go (right): https://codereview.appspot.com/120140044/diff/40001/src/pkg/sync/atomic/value_test.go#newcode51 src/pkg/sync/atomic/value_test.go:51: if err == nil || err.(string) != nilErr { ...
9 years, 9 months ago (2014-07-24 17:48:39 UTC) #1
josharian
Why disallow Store(nil)?
9 years, 9 months ago (2014-07-24 23:54:58 UTC) #2
dvyukov
On 2014/07/24 23:54:58, josharian wrote: > Why disallow Store(nil)? What would be a use case ...
9 years, 9 months ago (2014-07-25 07:59:08 UTC) #3
dvyukov
On 2014/07/24 23:54:58, josharian wrote: > Why disallow Store(nil)? What would be a use case ...
9 years, 9 months ago (2014-07-25 07:59:08 UTC) #4
dvyukov
https://codereview.appspot.com/120140044/diff/40001/src/pkg/sync/atomic/value_test.go File src/pkg/sync/atomic/value_test.go (right): https://codereview.appspot.com/120140044/diff/40001/src/pkg/sync/atomic/value_test.go#newcode51 src/pkg/sync/atomic/value_test.go:51: if err == nil || err.(string) != nilErr { ...
9 years, 9 months ago (2014-07-25 08:17:21 UTC) #5
dvyukov
Added sketch of a second example for the component.
9 years, 9 months ago (2014-07-25 08:17:52 UTC) #6
dvyukov
Added Value.Read benchmark: BenchmarkValueRead 50000000 21.7 ns/op BenchmarkValueRead-2 200000000 8.63 ns/op BenchmarkValueRead-4 300000000 4.33 ns/op ...
9 years, 9 months ago (2014-07-25 10:39:47 UTC) #7
ruiu
https://codereview.appspot.com/120140044/diff/100001/src/pkg/sync/atomic/asm_amd64.s File src/pkg/sync/atomic/asm_amd64.s (right): https://codereview.appspot.com/120140044/diff/100001/src/pkg/sync/atomic/asm_amd64.s#newcode155 src/pkg/sync/atomic/asm_amd64.s:155: MOVQ 8(BP), CX // load word Can this be ...
9 years, 9 months ago (2014-07-25 20:05:15 UTC) #8
dvyukov
On 2014/07/25 20:05:15, ruiu wrote: > https://codereview.appspot.com/120140044/diff/100001/src/pkg/sync/atomic/asm_amd64.s > File src/pkg/sync/atomic/asm_amd64.s (right): > > https://codereview.appspot.com/120140044/diff/100001/src/pkg/sync/atomic/asm_amd64.s#newcode155 > ...
9 years, 9 months ago (2014-07-28 13:50:41 UTC) #9
josharian
> > Why disallow Store(nil)? > > What would be a use case for this? ...
9 years, 9 months ago (2014-07-28 18:13:20 UTC) #10
dvyukov
On 2014/07/28 18:13:20, josharian wrote: > > > Why disallow Store(nil)? > > > > ...
9 years, 9 months ago (2014-07-29 04:37:36 UTC) #11
josharian
> In either case I would like to hear from Rob before we start evolving ...
9 years, 9 months ago (2014-07-29 05:40:27 UTC) #12
rsc
Can you send a separate CL showing how this would be used in encoding/gob and ...
9 years, 8 months ago (2014-08-05 04:34:06 UTC) #13
dvyukov
On 2014/08/05 04:34:06, rsc wrote: > Can you send a separate CL showing how this ...
9 years, 8 months ago (2014-08-05 11:37:43 UTC) #14
r
Yesterday I checked in https://codereview.appspot.com/117520043, which hoisted a call to userType out of the struct-encoding ...
9 years, 8 months ago (2014-08-05 13:49:15 UTC) #15
dvyukov
On Tue, Aug 5, 2014 at 5:48 PM, Rob Pike <r@golang.org> wrote: > Yesterday I ...
9 years, 8 months ago (2014-08-05 14:02:06 UTC) #16
r
I like the API. https://codereview.appspot.com/120140044/diff/110001/src/pkg/sync/atomic/value.go File src/pkg/sync/atomic/value.go (right): https://codereview.appspot.com/120140044/diff/110001/src/pkg/sync/atomic/value.go#newcode16 src/pkg/sync/atomic/value.go:16: // It returns nil if ...
9 years, 8 months ago (2014-08-05 20:59:02 UTC) #17
dvyukov
So what is the decision with this component? Do I need to add implementations for ...
9 years, 8 months ago (2014-08-05 21:16:53 UTC) #18
rsc
Yes, please implement the others. Then please do a real hg mail so that it ...
9 years, 8 months ago (2014-08-05 21:25:57 UTC) #19
dvyukov
Hello rsc@golang.org, josharian@gmail.com, r@golang.org, ruiu@google.com (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to ...
9 years, 8 months ago (2014-08-07 19:47:07 UTC) #20
dvyukov
Added TestValueConcurrent test
9 years, 8 months ago (2014-08-07 20:15:05 UTC) #21
dvyukov
I have not tested arm code, just compiled if. Dave, can you please test it. ...
9 years, 8 months ago (2014-08-07 20:45:03 UTC) #22
dvyukov
ping
9 years, 8 months ago (2014-08-12 20:35:10 UTC) #23
r
Waiting for tests on other architectures. Or should we submit and watch the builders break? ...
9 years, 8 months ago (2014-08-12 20:39:29 UTC) #24
minux
so you're not doing atomic stores yet, right? https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s File src/pkg/sync/atomic/value_arm.s (right): https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s#newcode14 src/pkg/sync/atomic/value_arm.s:14: MOVW ...
9 years, 8 months ago (2014-08-12 20:43:07 UTC) #25
dvyukov
On Wed, Aug 13, 2014 at 12:43 AM, <minux@golang.org> wrote: > so you're not doing ...
9 years, 8 months ago (2014-08-12 20:45:49 UTC) #26
dvyukov
https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s File src/pkg/sync/atomic/value_arm.s (right): https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s#newcode14 src/pkg/sync/atomic/value_arm.s:14: MOVW 4(R0), R2 // load word On 2014/08/12 20:43:07, ...
9 years, 8 months ago (2014-08-12 20:53:28 UTC) #27
dvyukov
On 2014/08/12 20:53:28, dvyukov wrote: > https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s > File src/pkg/sync/atomic/value_arm.s (right): > > https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s#newcode14 > ...
9 years, 8 months ago (2014-08-12 21:02:33 UTC) #28
minux
On Tue, Aug 12, 2014 at 4:45 PM, Dmitry Vyukov <dvyukov@google.com> wrote: > On Wed, ...
9 years, 8 months ago (2014-08-12 21:08:40 UTC) #29
minux
https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s File src/pkg/sync/atomic/value_arm.s (right): https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s#newcode24 src/pkg/sync/atomic/value_arm.s:24: BEQ value_store_nil On 2014/08/12 20:53:28, dvyukov wrote: > Does ...
9 years, 8 months ago (2014-08-12 21:10:51 UTC) #30
dvyukov
On Wed, Aug 13, 2014 at 1:08 AM, minux <minux@golang.org> wrote: > > On Tue, ...
9 years, 8 months ago (2014-08-12 21:15:31 UTC) #31
dvyukov
https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s File src/pkg/sync/atomic/value_arm.s (right): https://codereview.appspot.com/120140044/diff/270001/src/pkg/sync/atomic/value_arm.s#newcode24 src/pkg/sync/atomic/value_arm.s:24: BEQ value_store_nil On 2014/08/12 21:10:51, minux wrote: > On ...
9 years, 8 months ago (2014-08-12 21:15:41 UTC) #32
minux
On Tue, Aug 12, 2014 at 5:15 PM, Dmitry Vyukov <dvyukov@google.com> wrote: > On Wed, ...
9 years, 8 months ago (2014-08-12 21:17:19 UTC) #33
rsc
This doesn't need to happen today. Please let Minux work on power64 for the rest ...
9 years, 8 months ago (2014-08-12 21:17:51 UTC) #34
rsc
I don't understand why we are using the word 'component'. I've never seen that word ...
9 years, 8 months ago (2014-08-20 18:23:44 UTC) #35
rsc
R=rsc I still need to read the assembly. The rest looks good. https://codereview.appspot.com/120140044/diff/290001/src/pkg/sync/atomic/norace.go File src/pkg/sync/atomic/norace.go ...
9 years, 8 months ago (2014-08-20 18:28:51 UTC) #36
dvyukov
https://codereview.appspot.com/120140044/diff/290001/src/pkg/sync/atomic/norace.go File src/pkg/sync/atomic/norace.go (right): https://codereview.appspot.com/120140044/diff/290001/src/pkg/sync/atomic/norace.go#newcode9 src/pkg/sync/atomic/norace.go:9: import ( On 2014/08/20 18:28:50, rsc wrote: > drop ...
9 years, 8 months ago (2014-08-21 10:14:00 UTC) #37
dvyukov
On 2014/08/20 18:23:44, rsc wrote: > I don't understand why we are using the word ...
9 years, 8 months ago (2014-08-21 10:14:57 UTC) #38
rsc
Right now it looks to me like the assembly for load loads the type word ...
9 years, 8 months ago (2014-08-24 01:49:44 UTC) #39
dvyukov
Done PTAL
9 years, 8 months ago (2014-08-26 16:29:30 UTC) #40
rsc
LGTM
9 years, 7 months ago (2014-09-16 20:40:32 UTC) #41
dvyukov
9 years, 7 months ago (2014-09-17 02:53:15 UTC) #42
I've recreated this CL as:
https://codereview.appspot.com/136710045

It's all broken after pkg move.
It does not apply in a new client:
$ hg clpatch 120140044
unexpected chunk header line: @@ --266,6 +-266,16 @@

and in old client I can't upload it:
$ hg upload 120140044
abort: src/sync/atomic/norace.go@c79b24056eb1: not found in manifest!
Sign in to reply to this message.

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