]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.9] runtime: use simple, more robust fastrandn
authorRuss Cox <rsc@golang.org>
Sun, 15 Oct 2017 02:47:24 +0000 (22:47 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 25 Oct 2017 20:24:03 +0000 (20:24 +0000)
commitd93cb46280ae4710c5c6113159c7973a08a72249
tree6b3cac482598e995b5fd727ea574a50611d12997
parent78952c06c53c8455d03430b17b5a7fe2693b5d35
[release-branch.go1.9] runtime: use simple, more robust fastrandn

CL 36932 (speed up fastrandn) made it faster but introduced
bad interference with some properties of fastrand itself, making
fastrandn not very random in certain ways. In particular, certain
selects are demonstrably unfair.

For Go 1.10 the new faster fastrandn has induced a new fastrand,
which in turn has caused other follow-on bugs that are still being
discovered and fixed.

For Go 1.9.2, just go back to the barely slower % implementation
that we used in Go 1.8 and earlier. This should restore fairness in
select and any other problems caused by the clever fastrandn.

The test in this CL is copied from CL 62530.

Fixes #22253.

Change-Id: Ibcf948a7bce981452e05c90dbdac122043f6f813
Reviewed-on: https://go-review.googlesource.com/70991
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/chan_test.go
src/runtime/stubs.go