cmd/trace: fix a runnable goroutine count bug

When starting tracing, EvGoCreate events are added for existing
goroutines that may have been blocking in syscall. EvGoCreate
increments the runnable goroutine count. This change makes the
following EvGoInSyscall event decrement the runnable goroutine count
because we now know that goroutine is in syscall, and not runnable.

Made generateTrace return an error, at any given time, the number
of runnable/running/insyscall goroutines becomes non-negative.

Added a basic test that checks the number of runnable/running
goroutines don't include the goroutines in syscall - the test failed
before this change.

Change-Id: Ib732c382e7bd17158a437576f9d589ab89097ce6
Reviewed-on: https://go-review.googlesource.com/25552
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
This commit is contained in:
Hyang-Ah (Hana) Kim 2016-08-08 17:24:07 -04:00 committed by Hyang-Ah Hana Kim
parent dd307da10c
commit c24cc40075
5 changed files with 145 additions and 63 deletions

View file

@ -89,7 +89,10 @@ func main() {
events: events,
endTime: int64(1<<63 - 1),
}
data := generateTrace(params)
data, err := generateTrace(params)
if err != nil {
dief("%v\n", err)
}
log.Printf("Splitting trace...")
ranges = splitTrace(data)