]> Cypherpunks repositories - gostls13.git/commit
math/rand: devirtualize interface in lockedSource
authorCarlo Alberto Ferraris <cafxx@strayorange.com>
Fri, 23 Aug 2019 23:59:01 +0000 (08:59 +0900)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Sun, 29 Sep 2019 14:27:05 +0000 (14:27 +0000)
commit931365763a294950200096d071a35f799ffade2c
treead6eb4ac98137df44e6a3b0dc74f5c7bcb4f378e
parent57662b1575030aa09043cd7a48425abdc6e0e0a3
math/rand: devirtualize interface in lockedSource

Avoid interface calls, enable inlining, and store the rngSource close to the
Mutex to exploit better memory locality.

Also add a benchmark to properly measure the threadsafe nature of globalRand.

On a linux/amd64 VM:

name                       old time/op  new time/op  delta
Int63Threadsafe-4          36.4ns ±12%  20.6ns ±11%  -43.52%  (p=0.000 n=30+30)
Int63ThreadsafeParallel-4  79.3ns ± 5%  56.5ns ± 5%  -28.69%  (p=0.000 n=29+30)

Change-Id: I6ab912c1a1e9afc7bacd8e72c82d4d50d546a510
Reviewed-on: https://go-review.googlesource.com/c/go/+/191538
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/inl_test.go
src/math/rand/rand.go
src/math/rand/rand_test.go