[go: nahoru, domu]

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

Issue 7080005: Fix base::RandGenerator bug (it had non-uniform random distribution). (Closed)

Created:
9 years, 7 months ago by Jói
Modified:
9 years, 6 months ago
CC:
chromium-reviews, Paweł Hajdan Jr., brettw-cc_chromium.org
Visibility:
Public.

Description

Fix base::RandGenerator bug (it had non-uniform random distribution). Add test that would have caught bug. Also add a test to verify that our random generators are at least somewhat random. BUG=84221 TEST=base_unittests --gtest_filter=RandUtilTest.* Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=87244

Patch Set 1 #

Total comments: 15

Patch Set 2 : Respond to review comments. #

Total comments: 3

Patch Set 3 : Fix issue pointed out by jar@ #

Total comments: 1

Patch Set 4 : Add "all bit values" test as suggested by jar@. #

Total comments: 2

Patch Set 5 : Switch to 3/4ths R for max. #

Patch Set 6 : Switch to bitwise operations. Max to 1000. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+75 lines, -1 line) Patch
M base/rand_util.cc View 1 2 1 chunk +14 lines, -1 line 0 comments Download
M base/rand_util_unittest.cc View 1 2 3 4 5 2 chunks +61 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
Jói
Ilya: Main reviewer. Brett: base/OWNERS approval. Cheers, Jói
9 years, 7 months ago (2011-05-27 18:03:16 UTC) #1
brettw
http://codereview.chromium.org/7080005/diff/1/base/rand_util_unittest.cc File base/rand_util_unittest.cc (right): http://codereview.chromium.org/7080005/diff/1/base/rand_util_unittest.cc#newcode65 base/rand_util_unittest.cc:65: TEST(RandUtilTest, RandGeneratorIsUniform) { I'm not super excited about this ...
9 years, 7 months ago (2011-05-27 18:13:21 UTC) #2
Jói
It takes 5 seconds to run if it never converges (on a not-so-fast Linux box). ...
9 years, 7 months ago (2011-05-27 18:17:13 UTC) #3
brettw
I'm interested in Pawel's opinion on whether this test is useful. http://codereview.chromium.org/7080005/diff/1/base/rand_util_unittest.cc File base/rand_util_unittest.cc (right): ...
9 years, 7 months ago (2011-05-27 18:22:20 UTC) #4
Jói
Well, the test is useful in that it shows the previous implementation did not generate ...
9 years, 7 months ago (2011-05-27 18:24:11 UTC) #5
Jói
Just as a further data point, running the test with --gtest_repeat=10000 took 2m23s wall-clock time, ...
9 years, 7 months ago (2011-05-27 18:42:00 UTC) #6
Ilya Sherman
+ Jim for comment on probabilistic tests, as I think he's contributed a few to ...
9 years, 7 months ago (2011-05-27 19:23:26 UTC) #7
Paweł Hajdan Jr.
Some comments, no need to wait for me. One note though: if more and more ...
9 years, 7 months ago (2011-05-27 19:28:11 UTC) #8
Jói
Thanks for the reviews guys. It seems several pieces of production code depend on RandGenerator ...
9 years, 7 months ago (2011-05-27 19:41:48 UTC) #9
brettw
LGTM
9 years, 7 months ago (2011-05-27 20:01:56 UTC) #10
jar (doing other things)
http://codereview.chromium.org/7080005/diff/4003/base/rand_util.cc File base/rand_util.cc (right): http://codereview.chromium.org/7080005/diff/4003/base/rand_util.cc#newcode59 base/rand_util.cc:59: } while (value > max_acceptable_value); Very cute.... but I ...
9 years, 7 months ago (2011-05-27 20:25:14 UTC) #11
Jói
http://codereview.chromium.org/7080005/diff/4003/base/rand_util.cc File base/rand_util.cc (right): http://codereview.chromium.org/7080005/diff/4003/base/rand_util.cc#newcode59 base/rand_util.cc:59: } while (value > max_acceptable_value); On 2011/05/27 20:25:14, jar ...
9 years, 7 months ago (2011-05-27 23:18:01 UTC) #12
jar (doing other things)
Note: I don't think I wrote the original code... and I'm not blocking the change ...
9 years, 7 months ago (2011-05-28 17:26:40 UTC) #13
Jói
Hi Jim, First off, this bug wasn't affecting me in any practical way (Ilya asked ...
9 years, 6 months ago (2011-05-30 15:31:42 UTC) #14
jar (doing other things)
On Mon, May 30, 2011 at 8:31 AM, Jói Sigurðsson <joi@chromium.org> wrote: > Hi Jim, ...
9 years, 6 months ago (2011-05-30 16:40:41 UTC) #15
Jói
Thanks Jim. Let me know when I have your LGTM for the added test. > ...
9 years, 6 months ago (2011-05-30 16:47:03 UTC) #16
jar (doing other things)
Thanks for adding this as well. See comment. If you really like the current form ...
9 years, 6 months ago (2011-05-30 17:02:07 UTC) #17
Jói
Heh, no, the bitwise approach is much nicer, I've updated to that. I blame not ...
9 years, 6 months ago (2011-05-30 17:16:38 UTC) #18
jar (doing other things)
9 years, 6 months ago (2011-05-30 17:23:12 UTC) #19
LGTM

Powered by Google App Engine
This is Rietveld 408576698