]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.8] runtime: avoid O(n) semaphore list walk in contention profiling
authorRuss Cox <rsc@golang.org>
Thu, 23 Feb 2017 20:13:25 +0000 (15:13 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 27 Feb 2017 17:34:28 +0000 (17:34 +0000)
Contention profiling is off by default.
If you turn it on, it has the unfortunate effect of making
the wakeup on a contention mutex go from O(1) to O(n).
Change it back to O(1).

This is already fixed in essentially the same way on master;
master also contains some fixes for the non-profiling code
paths.

Possible for Go 1.8.1.

Change-Id: Iaa644c06e20ca28da4dfa348b7211eedb657e0ba
Reviewed-on: https://go-review.googlesource.com/37341
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/sema.go

index 576a1fb7a207f56eb08a6e6ff67f113535e2b291..37318ff9d55cd387a6617532e89c9a8eb6c87337 100644 (file)
@@ -171,6 +171,7 @@ func semrelease(addr *uint32) {
                        for x := root.head; x != nil; x = x.next {
                                if x.elem == unsafe.Pointer(addr) {
                                        x.acquiretime = t0
+                                       break
                                }
                        }
                        mutexevent(t0-s.acquiretime, 3)