mirror of
https://github.com/golang/go
synced 2024-11-19 07:44:49 -07:00
cmd/trace: dump thread id on proc start
Augment ProcStart events with OS thread id. This helps in scheduler locality analysis. Change-Id: I93fea75d3072cf68de66110d0b59d07101badcb5 Reviewed-on: https://go-review.googlesource.com/7302 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
b2843becab
commit
9d332a8324
@ -391,7 +391,14 @@ func (ctx *traceContext) emitThreadCounters(ev *trace.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *traceContext) emitInstant(ev *trace.Event, name string) {
|
func (ctx *traceContext) emitInstant(ev *trace.Event, name string) {
|
||||||
ctx.emit(&ViewerEvent{Name: name, Phase: "I", Scope: "t", Time: ctx.time(ev), Tid: ctx.proc(ev), Stack: ctx.stack(ev.Stk)})
|
var arg interface{}
|
||||||
|
if ev.Type == trace.EvProcStart {
|
||||||
|
type Arg struct {
|
||||||
|
ThreadID uint64
|
||||||
|
}
|
||||||
|
arg = &Arg{ev.Args[0]}
|
||||||
|
}
|
||||||
|
ctx.emit(&ViewerEvent{Name: name, Phase: "I", Scope: "t", Time: ctx.time(ev), Tid: ctx.proc(ev), Stack: ctx.stack(ev.Stk), Arg: arg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *traceContext) emitArrow(ev *trace.Event, name string) {
|
func (ctx *traceContext) emitArrow(ev *trace.Event, name string) {
|
||||||
|
@ -584,7 +584,7 @@ const (
|
|||||||
EvFrequency = 2 // contains tracer timer frequency [frequency (ticks per second)]
|
EvFrequency = 2 // contains tracer timer frequency [frequency (ticks per second)]
|
||||||
EvStack = 3 // stack [stack id, number of PCs, array of PCs]
|
EvStack = 3 // stack [stack id, number of PCs, array of PCs]
|
||||||
EvGomaxprocs = 4 // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack id]
|
EvGomaxprocs = 4 // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack id]
|
||||||
EvProcStart = 5 // start of P [timestamp]
|
EvProcStart = 5 // start of P [timestamp, thread id]
|
||||||
EvProcStop = 6 // stop of P [timestamp]
|
EvProcStop = 6 // stop of P [timestamp]
|
||||||
EvGCStart = 7 // GC start [timestamp, stack id]
|
EvGCStart = 7 // GC start [timestamp, stack id]
|
||||||
EvGCDone = 8 // GC done [timestamp]
|
EvGCDone = 8 // GC done [timestamp]
|
||||||
@ -628,7 +628,7 @@ var EventDescriptions = [EvCount]struct {
|
|||||||
EvFrequency: {"Frequency", false, []string{"freq"}},
|
EvFrequency: {"Frequency", false, []string{"freq"}},
|
||||||
EvStack: {"Stack", false, []string{"id", "siz"}},
|
EvStack: {"Stack", false, []string{"id", "siz"}},
|
||||||
EvGomaxprocs: {"Gomaxprocs", true, []string{"procs"}},
|
EvGomaxprocs: {"Gomaxprocs", true, []string{"procs"}},
|
||||||
EvProcStart: {"ProcStart", false, []string{}},
|
EvProcStart: {"ProcStart", false, []string{"thread"}},
|
||||||
EvProcStop: {"ProcStop", false, []string{}},
|
EvProcStop: {"ProcStop", false, []string{}},
|
||||||
EvGCStart: {"GCStart", true, []string{}},
|
EvGCStart: {"GCStart", true, []string{}},
|
||||||
EvGCDone: {"GCDone", false, []string{}},
|
EvGCDone: {"GCDone", false, []string{}},
|
||||||
|
@ -101,7 +101,7 @@ func TestTraceStress(t *testing.T) {
|
|||||||
<-done
|
<-done
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond) // give the goroutine above time to block
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
if err := StartTrace(buf); err != nil {
|
if err := StartTrace(buf); err != nil {
|
||||||
@ -109,6 +109,7 @@ func TestTraceStress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
procs := runtime.GOMAXPROCS(10)
|
procs := runtime.GOMAXPROCS(10)
|
||||||
|
time.Sleep(50 * time.Millisecond) // test proc stop/start events
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
@ -21,7 +21,7 @@ const (
|
|||||||
traceEvFrequency = 2 // contains tracer timer frequency [frequency (ticks per second)]
|
traceEvFrequency = 2 // contains tracer timer frequency [frequency (ticks per second)]
|
||||||
traceEvStack = 3 // stack [stack id, number of PCs, array of PCs]
|
traceEvStack = 3 // stack [stack id, number of PCs, array of PCs]
|
||||||
traceEvGomaxprocs = 4 // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack id]
|
traceEvGomaxprocs = 4 // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack id]
|
||||||
traceEvProcStart = 5 // start of P [timestamp]
|
traceEvProcStart = 5 // start of P [timestamp, thread id]
|
||||||
traceEvProcStop = 6 // stop of P [timestamp]
|
traceEvProcStop = 6 // stop of P [timestamp]
|
||||||
traceEvGCStart = 7 // GC start [timestamp, stack id]
|
traceEvGCStart = 7 // GC start [timestamp, stack id]
|
||||||
traceEvGCDone = 8 // GC done [timestamp]
|
traceEvGCDone = 8 // GC done [timestamp]
|
||||||
@ -716,7 +716,7 @@ func traceGomaxprocs(procs int32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func traceProcStart() {
|
func traceProcStart() {
|
||||||
traceEvent(traceEvProcStart, -1)
|
traceEvent(traceEvProcStart, -1, uint64(getg().m.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func traceProcStop(pp *p) {
|
func traceProcStop(pp *p) {
|
||||||
|
Loading…
Reference in New Issue
Block a user