Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Issue 2588213002: Use global rand.Rand instance in mathrand. (Closed)

Created:
4 years ago by dnj
Modified:
4 years ago
Reviewers:
Vadim Sh.
CC:
chromium-reviews, infra-reviews+luci-go_chromium.org, maruel+w_chromium.org, tandrii+luci-go_chromium.org
Target Ref:
refs/heads/master
Project:
luci-go
Visibility:
Public.

Description

Use global rand.Rand instance in mathrand. By default, mathrand will use a new *rand.Rand if none is installed in the Context. This leads to a very bad performance case if the user forgets to install an instance in the Context! Now that we have locking, use a single global rand.Rand instance. The user can always change this if they want. Update all of the global functons to use our global interface instead of the rand.Rand package one. Additionally, as an optimization, remove "defer" calls from the Locking wrapper. This speeds up operations by a factor of 3x. BUG=chromium:675813 TEST=None Review-Url: https://codereview.chromium.org/2588213002 Committed: https://github.com/luci/luci-go/commit/f469f2540cad71872c674950f530bdbc5de13e02

Patch Set 1 #

Total comments: 4

Patch Set 2 : Global rand, remove defers #

Patch Set 3 : Update comments. #

Patch Set 4 : Better comment. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+188 lines, -162 lines) Patch
M appengine/gaemiddleware/context.go View 1 3 chunks +0 lines, -8 lines 0 comments Download
M common/data/rand/mathrand/impl.go View 1 6 chunks +60 lines, -39 lines 0 comments Download
M common/data/rand/mathrand/mathrand.go View 1 2 3 5 chunks +61 lines, -109 lines 0 comments Download
M common/data/rand/mathrand/mathrand_test.go View 1 4 chunks +67 lines, -6 lines 2 comments Download

Messages

Total messages: 12 (5 generated)
dnj
4 years ago (2016-12-20 01:32:07 UTC) #1
Vadim Sh.
https://codereview.chromium.org/2588213002/diff/1/common/data/rand/mathrand/mathrand.go File common/data/rand/mathrand/mathrand.go (right): https://codereview.chromium.org/2588213002/diff/1/common/data/rand/mathrand/mathrand.go#newcode58 common/data/rand/mathrand/mathrand.go:58: // Generate a new Rand instance and return it. ...
4 years ago (2016-12-20 01:40:38 UTC) #2
dnj
https://codereview.chromium.org/2588213002/diff/1/common/data/rand/mathrand/mathrand.go File common/data/rand/mathrand/mathrand.go (right): https://codereview.chromium.org/2588213002/diff/1/common/data/rand/mathrand/mathrand.go#newcode58 common/data/rand/mathrand/mathrand.go:58: // Generate a new Rand instance and return it. ...
4 years ago (2016-12-20 02:16:12 UTC) #5
Vadim Sh.
lgtm https://codereview.chromium.org/2588213002/diff/60001/common/data/rand/mathrand/mathrand_test.go File common/data/rand/mathrand/mathrand_test.go (right): https://codereview.chromium.org/2588213002/diff/60001/common/data/rand/mathrand/mathrand_test.go#newcode174 common/data/rand/mathrand/mathrand_test.go:174: // BenchmarkOurDefaultSourceViaCtx-32 20000000 77.8 ns/op awesome!
4 years ago (2016-12-20 02:31:56 UTC) #6
dnj
https://codereview.chromium.org/2588213002/diff/60001/common/data/rand/mathrand/mathrand_test.go File common/data/rand/mathrand/mathrand_test.go (right): https://codereview.chromium.org/2588213002/diff/60001/common/data/rand/mathrand/mathrand_test.go#newcode174 common/data/rand/mathrand/mathrand_test.go:174: // BenchmarkOurDefaultSourceViaCtx-32 20000000 77.8 ns/op On 2016/12/20 02:31:56, Vadim ...
4 years ago (2016-12-20 02:36:07 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2588213002/60001
4 years ago (2016-12-20 02:36:18 UTC) #9
commit-bot: I haz the power
4 years ago (2016-12-20 02:47:17 UTC) #12
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as
https://github.com/luci/luci-go/commit/f469f2540cad71872c674950f530bdbc5de13e02

Powered by Google App Engine
This is Rietveld 408576698