From: Dmitry Vyukov Date: Tue, 27 Jan 2015 19:55:03 +0000 (+0300) Subject: runtime: simplify code X-Git-Tag: go1.5beta1~2254 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6d37c830b6bcf466cd03463c20843a89a22d0a23;p=gostls13.git runtime: simplify code The %61 hack was added when runtime was is in C. Now the Go compiler does the optimization. Change-Id: I79c3302ec4b931eaaaaffe75e7101c92bf287fc7 Reviewed-on: https://go-review.googlesource.com/3289 Reviewed-by: Keith Randall --- diff --git a/src/runtime/proc1.go b/src/runtime/proc1.go index 1950403329..39e8094578 100644 --- a/src/runtime/proc1.go +++ b/src/runtime/proc1.go @@ -1429,10 +1429,7 @@ top: // Check the global runnable queue once in a while to ensure fairness. // Otherwise two goroutines can completely occupy the local runqueue // by constantly respawning each other. - tick := _g_.m.p.schedtick - // This is a fancy way to say tick%61==0, - // it uses 2 MUL instructions instead of a single DIV and so is faster on modern processors. - if uint64(tick)-((uint64(tick)*0x4325c53f)>>36)*61 == 0 && sched.runqsize > 0 { + if _g_.m.p.schedtick%61 == 0 && sched.runqsize > 0 { lock(&sched.lock) gp = globrunqget(_g_.m.p, 1) unlock(&sched.lock)