]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: add fastrand64
authorzhangyunhao <zhangyunhao@bytedance.com>
Mon, 18 Apr 2022 07:23:20 +0000 (15:23 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 20 Apr 2022 22:50:33 +0000 (22:50 +0000)
commitebe1435fbb50bb82bfca53063e8daba4f870ec8d
treed14d2583cbcdcd519ce32def65497fe2dce30f43
parent6de00888e4720b7fa23ef2ce294bc3e81b866b0f
runtime: add fastrand64

Support fastrand64 in the runtime, although fastrand uses wyrand to generate 64-bit random number, it still returns uint32. In some cases, we need to generate a 64-bit random number, the new API would be faster and easier to use, and at least we can use the new function in these places:

src/net/dnsclient.go:randInt()
src/hash/maphash/maphash.go:MakeSeed()
src/runtime/map.go:mapiterinit()

name                 time/op
Fastrand-16          0.09ns ± 5%
Fastrand64-16        0.09ns ± 6%

Change-Id: Ibb97378c7ca59bc7dc15535d4872fa58ea112e6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/400734
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/runtime/export_test.go
src/runtime/rand_test.go
src/runtime/stubs.go