Commit 9a0fd97f authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

runtime: remove a modulus calculation from pollorder

This is a follow-up to CL 9269, as suggested
by dvyukov.

There is probably even more that can be done
to speed up this shuffle. It will matter more
once CL 7570 (fine-grained locking in select)
is in and can be revisited then, with benchmarks.

Change-Id: Ic13a27d11cedd1e1f007951214b3bb56b1644f02
Reviewed-on: https://go-review.googlesource.com/9393Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
parent 1b01910c
......@@ -243,7 +243,7 @@ func selectgoImpl(sel *hselect) (uintptr, uint16) {
// generate permuted order
pollslice := slice{unsafe.Pointer(sel.pollorder), int(sel.ncase), int(sel.ncase)}
pollorder := *(*[]uint16)(unsafe.Pointer(&pollslice))
for i := 0; i < int(sel.ncase); i++ {
for i := 1; i < int(sel.ncase); i++ {
j := int(fastrand1()) % (i + 1)
pollorder[i] = pollorder[j]
pollorder[j] = uint16(i)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment