When mathrand is not installed in a Context, each Get call instantiates a new one! |
||
Issue descriptionThis is the case for AppEngine instances. Currently, each mathrand call (datastore cache filter) will cause a new Rand to be initialized. This ruins randomness and also costs a lot. We should replace this with a global rand instance now that we have locking.
,
Dec 20 2016
The following revision refers to this bug: https://chromium.googlesource.com/external/github.com/luci/luci-go.git/+/f469f2540cad71872c674950f530bdbc5de13e02 commit f469f2540cad71872c674950f530bdbc5de13e02 Author: dnj <dnj@chromium.org> Date: Tue Dec 20 02:47:13 2016 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 [modify] https://crrev.com/f469f2540cad71872c674950f530bdbc5de13e02/appengine/gaemiddleware/context.go [modify] https://crrev.com/f469f2540cad71872c674950f530bdbc5de13e02/common/data/rand/mathrand/impl.go [modify] https://crrev.com/f469f2540cad71872c674950f530bdbc5de13e02/common/data/rand/mathrand/mathrand.go [modify] https://crrev.com/f469f2540cad71872c674950f530bdbc5de13e02/common/data/rand/mathrand/mathrand_test.go
,
Dec 20 2016
|
||
►
Sign in to add a comment |
||
Comment 1 by d...@chromium.org
, Dec 20 2016