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

Issue 57270043: code review 57270043: testing: ease writing parallel benchmarks (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by dvyukov
Modified:
10 years, 2 months ago
Reviewers:
r, josharian, rsc, bradfitz
CC:
bradfitz, iant, josharian, btracey, r, rsc, gobot, golang-codereviews
Visibility:
Public.

Description

testing: ease writing parallel benchmarks Add b.RunParallel function that captures parallel benchmark boilerplate: creates worker goroutines, joins worker goroutines, distributes work among them in an efficient way, auto-tunes grain size. Fixes issue 7090.

Patch Set 1 #

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

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

Total comments: 1

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

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

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

Total comments: 8

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

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

Total comments: 12

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

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

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

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

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

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

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

Total comments: 33

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

Total comments: 22

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

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

Total comments: 2

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+236 lines, -145 lines) Patch
M doc/go1.3.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/chan_test.go View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +74 lines, -139 lines 0 comments Download
M src/pkg/testing/benchmark.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +91 lines, -6 lines 0 comments Download
M src/pkg/testing/benchmark_test.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +54 lines, -0 lines 0 comments Download
M src/pkg/testing/testing.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 chunks +16 lines, -0 lines 0 comments Download

Messages

Total messages: 61
bradfitz
https://codereview.appspot.com/57270043/diff/40001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/40001/src/pkg/testing/benchmark.go#newcode355 src/pkg/testing/benchmark.go:355: func (b *B) RunParallel2(P int, ctor func() func()) { ...
10 years, 2 months ago (2014-01-30 09:29:58 UTC) #1
dvyukov
Hello bradfitz@golang.org (cc: golang-codereviews@googlegroups.com, r@golang.org), I'd like you to review this change to https://dvyukov%40google.com@code.google.com/p/go/
10 years, 2 months ago (2014-01-30 10:33:16 UTC) #2
dvyukov
On 2014/01/30 09:29:58, bradfitz wrote: > https://codereview.appspot.com/57270043/diff/40001/src/pkg/testing/benchmark.go > File src/pkg/testing/benchmark.go (right): > > https://codereview.appspot.com/57270043/diff/40001/src/pkg/testing/benchmark.go#newcode355 > ...
10 years, 2 months ago (2014-01-30 10:33:38 UTC) #3
bradfitz
LGTM but wait for an API review from r or iant https://codereview.appspot.com/57270043/diff/100001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): ...
10 years, 2 months ago (2014-01-30 10:45:40 UTC) #4
dvyukov
https://codereview.appspot.com/57270043/diff/100001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/100001/src/pkg/testing/benchmark.go#newcode354 src/pkg/testing/benchmark.go:354: // A typical value for perProc for CPU bound ...
10 years, 2 months ago (2014-01-30 11:20:11 UTC) #5
dvyukov
And Go team must arrange for a persistent guest reviewer in Europe :)
10 years, 2 months ago (2014-01-30 11:21:20 UTC) #6
dvyukov
I think we need to somehow mention that it's intended to be used with "go ...
10 years, 2 months ago (2014-01-30 11:22:52 UTC) #7
bradfitz
Is AddUint32 faster than AddUint64? On Jan 30, 2014 12:20 PM, <dvyukov@google.com> wrote: > > ...
10 years, 2 months ago (2014-01-30 12:12:41 UTC) #8
dvyukov
It's probably a bit faster on 386: XADD vs CMPXCHG8B loop. It would matter more ...
10 years, 2 months ago (2014-01-30 12:20:23 UTC) #9
iant
https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go#newcode352 src/pkg/testing/benchmark.go:352: // It creates perProc*GOMAXPROCS worker goroutines I guess the ...
10 years, 2 months ago (2014-01-31 00:40:50 UTC) #10
dvyukov
https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go#newcode352 src/pkg/testing/benchmark.go:352: // It creates perProc*GOMAXPROCS worker goroutines On 2014/01/31 00:40:50, ...
10 years, 2 months ago (2014-01-31 09:26:21 UTC) #11
iant
https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go#newcode352 src/pkg/testing/benchmark.go:352: // It creates perProc*GOMAXPROCS worker goroutines On 2014/01/31 09:26:21, ...
10 years, 2 months ago (2014-01-31 14:45:00 UTC) #12
dvyukov
On Fri, Jan 31, 2014 at 6:45 PM, <iant@golang.org> wrote: > > https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go > File ...
10 years, 2 months ago (2014-01-31 15:00:30 UTC) #13
dvyukov
PTAL https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/140001/src/pkg/testing/benchmark.go#newcode352 src/pkg/testing/benchmark.go:352: // It creates perProc*GOMAXPROCS worker goroutines On 2014/01/31 ...
10 years, 2 months ago (2014-02-02 17:31:39 UTC) #14
dvyukov
On 2014/01/31 15:00:30, dvyukov wrote: > >> I believe that all of our benchmarks must ...
10 years, 2 months ago (2014-02-02 17:34:50 UTC) #15
josharian
On 2014/02/02 17:34:50, dvyukov wrote: > On 2014/01/31 15:00:30, dvyukov wrote: > > >> I ...
10 years, 2 months ago (2014-02-04 22:17:02 UTC) #16
btracey
Similarly, it would be great to have an auto-load-balanced parallel for loop provided (similar to ...
10 years, 2 months ago (2014-02-04 22:49:27 UTC) #17
dvyukov
On 2014/02/04 22:17:02, josharian wrote: > On 2014/02/02 17:34:50, dvyukov wrote: > > On 2014/01/31 ...
10 years, 2 months ago (2014-02-05 06:01:54 UTC) #18
josharian
On 2014/02/05 06:01:54, dvyukov wrote: > On 2014/02/04 22:17:02, josharian wrote: > > On 2014/02/02 ...
10 years, 2 months ago (2014-02-05 17:35:48 UTC) #19
dvyukov
On 2014/02/05 17:35:48, josharian wrote: > On 2014/02/05 06:01:54, dvyukov wrote: > > On 2014/02/04 ...
10 years, 2 months ago (2014-02-05 18:26:31 UTC) #20
josharian
On 2014/02/05 18:26:31, dvyukov wrote: > On 2014/02/05 17:35:48, josharian wrote: > > On 2014/02/05 ...
10 years, 2 months ago (2014-02-05 18:42:26 UTC) #21
iant
On Fri, Jan 31, 2014 at 7:00 AM, Dmitry Vyukov <dvyukov@google.com> wrote: > > On ...
10 years, 2 months ago (2014-02-05 21:30:47 UTC) #22
dvyukov
On 2014/02/05 21:30:47, iant wrote: > I guess the part I haven't managed to grasp ...
10 years, 2 months ago (2014-02-06 06:14:54 UTC) #23
dvyukov
Just for completeness few more alternatives: b.RunParallel(func(x *interface{}) { buf := (*x).(*bytes.Buffer) if buf == ...
10 years, 2 months ago (2014-02-06 06:26:55 UTC) #24
josharian
Here's yet another alternative, tweaking Ian's suggestion. (Let me know if you tire of this, ...
10 years, 2 months ago (2014-02-06 17:29:00 UTC) #25
dvyukov
On 2014/02/06 17:29:00, josharian wrote: > Here's yet another alternative, tweaking Ian's suggestion. (Let me ...
10 years, 2 months ago (2014-02-06 17:49:44 UTC) #26
bradfitz
I like it. On Feb 6, 2014 9:49 AM, <dvyukov@google.com> wrote: > On 2014/02/06 17:29:00, ...
10 years, 2 months ago (2014-02-06 17:50:34 UTC) #27
josharian
> I like it. +1
10 years, 2 months ago (2014-02-06 17:55:54 UTC) #28
dvyukov
Full example for completeness: // Parallel benchmark for text/template.Template.Execute on a single object. func BenchmarkTempl(b ...
10 years, 2 months ago (2014-02-06 18:01:24 UTC) #29
bradfitz
If PB had a Run method, we'd have a way to set options in the ...
10 years, 2 months ago (2014-02-06 18:38:22 UTC) #30
dvyukov
What do you mean by Run and Setters? On Thu, Feb 6, 2014 at 10:38 ...
10 years, 2 months ago (2014-02-06 19:43:14 UTC) #31
bradfitz
Sorry, was typing on a chairlift. b.NewParallel().Run(1, func(pb *testing.PB) { .... }) Then NewParallel can ...
10 years, 2 months ago (2014-02-06 19:47:58 UTC) #32
dvyukov
On Thu, Feb 6, 2014 at 11:47 PM, Brad Fitzpatrick <bradfitz@golang.org> wrote: > Sorry, was ...
10 years, 2 months ago (2014-02-06 19:57:45 UTC) #33
josharian
> > b.NewParallel().Run(1, func(pb *testing.PB) { > > .... > > }) > > > ...
10 years, 2 months ago (2014-02-08 02:03:27 UTC) #34
dvyukov
On Sat, Feb 8, 2014 at 6:03 AM, <josharian@gmail.com> wrote: >> > b.NewParallel().Run(1, func(pb *testing.PB) ...
10 years, 2 months ago (2014-02-08 16:13:15 UTC) #35
bradfitz
On Sat, Feb 8, 2014 at 8:12 AM, Dmitry Vyukov <dvyukov@google.com> wrote: > On Sat, ...
10 years, 2 months ago (2014-02-08 16:18:01 UTC) #36
dvyukov
On Sat, Feb 8, 2014 at 6:03 AM, <josharian@gmail.com> wrote: >> > b.NewParallel().Run(1, func(pb *testing.PB) ...
10 years, 2 months ago (2014-02-08 16:38:58 UTC) #37
dvyukov
Hi! I've updated the code to use the new interface. PTAL. Comments are more of ...
10 years, 2 months ago (2014-02-10 17:34:35 UTC) #38
bradfitz
https://codereview.appspot.com/57270043/diff/270001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/270001/src/pkg/testing/benchmark.go#newcode353 src/pkg/testing/benchmark.go:353: // PB is a helper type for RunParallel. Maybe: ...
10 years, 2 months ago (2014-02-10 19:37:05 UTC) #39
josharian
The suggested comment changes below are all just that -- suggested. Take of them what ...
10 years, 2 months ago (2014-02-10 20:19:31 UTC) #40
dvyukov
PTAL https://codereview.appspot.com/57270043/diff/270001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/270001/src/pkg/testing/benchmark.go#newcode40 src/pkg/testing/benchmark.go:40: lastDuration time.Duration On 2014/02/10 20:19:32, josharian wrote: > ...
10 years, 2 months ago (2014-02-11 11:31:13 UTC) #41
josharian
LGTM Thanks, Dmitry, this was really fun. https://codereview.appspot.com/57270043/diff/270001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/270001/src/pkg/testing/benchmark.go#newcode353 src/pkg/testing/benchmark.go:353: // PB ...
10 years, 2 months ago (2014-02-11 15:02:18 UTC) #42
bradfitz
I think this just needs an example now.
10 years, 2 months ago (2014-02-11 15:53:43 UTC) #43
dvyukov
there is an example On Tue, Feb 11, 2014 at 7:53 PM, <bradfitz@golang.org> wrote: > ...
10 years, 2 months ago (2014-02-11 15:54:26 UTC) #44
bradfitz
LGTM Whoops, I was only reading benchmark.go this latest round. On Tue, Feb 11, 2014 ...
10 years, 2 months ago (2014-02-11 15:57:05 UTC) #45
r
I'll take a look at the API later today. On Tue, Feb 11, 2014 at ...
10 years, 2 months ago (2014-02-11 16:34:13 UTC) #46
dvyukov
Thanks! Waiting for you. On Tue, Feb 11, 2014 at 8:33 PM, Rob Pike <r@golang.org> ...
10 years, 2 months ago (2014-02-11 16:37:01 UTC) #47
r
most of my comments are about documentation. the API looks really nice. https://codereview.appspot.com/57270043/diff/280001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go ...
10 years, 2 months ago (2014-02-11 22:57:17 UTC) #48
r
most of my comments are about documentation. the API looks really nice.
10 years, 2 months ago (2014-02-11 22:57:23 UTC) #49
r
most of my comments are about documentation. the API looks really nice.
10 years, 2 months ago (2014-02-11 22:57:28 UTC) #50
r
most of my comments are about documentation. the API looks really nice.
10 years, 2 months ago (2014-02-11 22:57:33 UTC) #51
r
most of my comments are about documentation. the API looks really nice.
10 years, 2 months ago (2014-02-11 22:57:33 UTC) #52
r
Sorry about the burst. The submit button wasn't showing evidence it had succeeded. On Tue, ...
10 years, 2 months ago (2014-02-11 22:58:34 UTC) #53
dvyukov
PTAL https://codereview.appspot.com/57270043/diff/280001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/280001/src/pkg/testing/benchmark.go#newcode39 src/pkg/testing/benchmark.go:39: lastN int // number of iterations in the ...
10 years, 2 months ago (2014-02-12 11:09:09 UTC) #54
dvyukov
Ian, Rob, final blessing?
10 years, 2 months ago (2014-02-16 08:39:36 UTC) #55
r
LGTM iant is on vacation. i think rsc should take a look too. https://codereview.appspot.com/57270043/diff/320001/src/pkg/testing/benchmark.go File ...
10 years, 2 months ago (2014-02-16 16:22:09 UTC) #56
gobot
R=rsc@golang.org (assigned by r@golang.org)
10 years, 2 months ago (2014-02-16 16:22:57 UTC) #57
dvyukov
waiting for Russ https://codereview.appspot.com/57270043/diff/320001/src/pkg/testing/benchmark.go File src/pkg/testing/benchmark.go (right): https://codereview.appspot.com/57270043/diff/320001/src/pkg/testing/benchmark.go#newcode422 src/pkg/testing/benchmark.go:422: // SetParallelism sets the number of ...
10 years, 2 months ago (2014-02-16 16:28:26 UTC) #58
rsc
LGTM nice
10 years, 2 months ago (2014-02-16 18:02:50 UTC) #59
r
I agree: nice. Thanks to everyone who pitched in. This is how to do API ...
10 years, 2 months ago (2014-02-16 20:45:19 UTC) #60
dvyukov
10 years, 2 months ago (2014-02-17 02:30:05 UTC) #61
*** Submitted as https://code.google.com/p/go/source/detail?r=355c9ac57116 ***

testing: ease writing parallel benchmarks
Add b.RunParallel function that captures parallel benchmark boilerplate:
creates worker goroutines, joins worker goroutines, distributes work
among them in an efficient way, auto-tunes grain size.
Fixes issue 7090.

R=bradfitz, iant, josharian, tracey.brendan, r, rsc, gobot
CC=golang-codereviews
https://codereview.appspot.com/57270043
Sign in to reply to this message.

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