]> Cypherpunks repositories - gostls13.git/commit
runtime: implement fastrand in go
authorSokolov Yura <funny.falcon@gmail.com>
Thu, 5 Jan 2017 06:36:27 +0000 (09:36 +0300)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 10 Feb 2017 19:16:29 +0000 (19:16 +0000)
commitd03c1248604679e1e6a01253144065bc57da48b8
treee668dc946c619cc67b9a5b79df244e58bf0b2233
parent9f75ecd5e12f2b9988086954933d610cd5647918
runtime: implement fastrand in go

So it could be inlined.

Using bit-tricks it could be implemented without condition
(improved trick version by Minux Ma).

Simple benchmark shows it is faster on i386 and x86_64, though
I don't know will it be faster on other architectures?

benchmark                       old ns/op     new ns/op     delta
BenchmarkFastrand-3             2.79          1.48          -46.95%
BenchmarkFastrandHashiter-3     25.9          24.9          -3.86%

Change-Id: Ie2eb6d0f598c0bb5fac7f6ad0f8b5e3eddaa361b
Reviewed-on: https://go-review.googlesource.com/34782
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
12 files changed:
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_amd64p32.s
src/runtime/asm_arm.s
src/runtime/asm_arm64.s
src/runtime/asm_mips64x.s
src/runtime/asm_mipsx.s
src/runtime/asm_ppc64x.s
src/runtime/asm_s390x.s
src/runtime/export_test.go
src/runtime/rand_test.go [new file with mode: 0644]
src/runtime/stubs.go