aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/select.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-03-11 18:29:12 +0300
committerDmitry Vyukov <dvyukov@google.com>2015-03-17 14:14:55 +0000
commit4396ea96c43e1df585c648762b6993e84cb6a2e5 (patch)
tree4cc0f995c0198be8060dd347b9523d430cc6d8ba /src/runtime/select.go
parent1b49a86ecece3978ceba60c372327b9cbcc68501 (diff)
downloadgo-4396ea96c43e1df585c648762b6993e84cb6a2e5.tar.xz
runtime: remove futile wakeups from trace
Channels and sync.Mutex'es allow another goroutine to acquire resource ahead of an unblocked goroutine. This is good for performance, but leads to futile wakeups (the unblocked goroutine needs to block again). Futile wakeups caused user confusion during the very first evaluation of tracing functionality on a real server (a goroutine as if acquires a mutex in a loop, while there is no loop in user code). This change detects futile wakeups on channels and emits a special event to denote the fact. Later parser finds entire wakeup sequences (unblock->start->block) and removes them. sync.Mutex will be supported in a separate change. Change-Id: Iaaaee9d5c0921afc62b449a97447445030ac19d3 Reviewed-on: https://go-review.googlesource.com/7380 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/select.go')
-rw-r--r--src/runtime/select.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/select.go b/src/runtime/select.go
index 73fcb439f1..98ac5a3d61 100644
--- a/src/runtime/select.go
+++ b/src/runtime/select.go
@@ -308,6 +308,7 @@ func selectgoImpl(sel *hselect) (uintptr, uint16) {
k *scase
sglist *sudog
sgnext *sudog
+ futile byte
)
loop:
@@ -392,7 +393,7 @@ loop:
// wait for someone to wake us up
gp.param = nil
- gopark(selparkcommit, unsafe.Pointer(sel), "select", traceEvGoBlockSelect, 2)
+ gopark(selparkcommit, unsafe.Pointer(sel), "select", traceEvGoBlockSelect|futile, 2)
// someone woke us up
sellock(sel)
@@ -435,6 +436,7 @@ loop:
}
if cas == nil {
+ futile = traceFutileWakeup
goto loop
}