mirror of https://github.com/golang/go.git
internal/trace: flags for what to include in GC utilization
Change-Id: I4ba963b003cb25b39d7575d423f17930d84f3f69 Reviewed-on: https://go-review.googlesource.com/c/60796 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
603af813d6
commit
27920c8ddc
|
|
@ -38,7 +38,7 @@ func getMMUCurve() ([]trace.MutatorUtil, *trace.MMUCurve, error) {
|
|||
if err != nil {
|
||||
mmuCache.err = err
|
||||
} else {
|
||||
mmuCache.util = tr.MutatorUtilization()
|
||||
mmuCache.util = tr.MutatorUtilization(trace.UtilSTW | trace.UtilBackground | trace.UtilAssist)
|
||||
mmuCache.mmuCurve = trace.NewMMUCurve(mmuCache.util)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -22,11 +22,27 @@ type MutatorUtil struct {
|
|||
Util float64
|
||||
}
|
||||
|
||||
// UtilFlags controls the behavior of MutatorUtilization.
|
||||
type UtilFlags int
|
||||
|
||||
const (
|
||||
// UtilSTW means utilization should account for STW events.
|
||||
UtilSTW UtilFlags = 1 << iota
|
||||
// UtilBackground means utilization should account for
|
||||
// background mark workers.
|
||||
UtilBackground
|
||||
// UtilAssist means utilization should account for mark
|
||||
// assists.
|
||||
UtilAssist
|
||||
// UtilSweep means utilization should account for sweeping.
|
||||
UtilSweep
|
||||
)
|
||||
|
||||
// MutatorUtilization returns the mutator utilization function for the
|
||||
// given trace. This function will always end with 0 utilization. The
|
||||
// bounds of the function are implicit in the first and last event;
|
||||
// outside of these bounds the function is undefined.
|
||||
func (p *Parsed) MutatorUtilization() []MutatorUtil {
|
||||
func (p *Parsed) MutatorUtilization(flags UtilFlags) []MutatorUtil {
|
||||
events := p.Events
|
||||
if len(events) == 0 {
|
||||
return nil
|
||||
|
|
@ -42,17 +58,33 @@ func (p *Parsed) MutatorUtilization() []MutatorUtil {
|
|||
case EvGomaxprocs:
|
||||
gomaxprocs = int(ev.Args[0])
|
||||
case EvGCSTWStart:
|
||||
stw++
|
||||
if flags&UtilSTW != 0 {
|
||||
stw++
|
||||
}
|
||||
case EvGCSTWDone:
|
||||
stw--
|
||||
if flags&UtilSTW != 0 {
|
||||
stw--
|
||||
}
|
||||
case EvGCMarkAssistStart:
|
||||
gcPs++
|
||||
assists[ev.G] = true
|
||||
if flags&UtilAssist != 0 {
|
||||
gcPs++
|
||||
assists[ev.G] = true
|
||||
}
|
||||
case EvGCMarkAssistDone:
|
||||
gcPs--
|
||||
delete(assists, ev.G)
|
||||
if flags&UtilAssist != 0 {
|
||||
gcPs--
|
||||
delete(assists, ev.G)
|
||||
}
|
||||
case EvGCSweepStart:
|
||||
if flags&UtilSweep != 0 {
|
||||
gcPs++
|
||||
}
|
||||
case EvGCSweepDone:
|
||||
if flags&UtilSweep != 0 {
|
||||
gcPs--
|
||||
}
|
||||
case EvGoStartLabel:
|
||||
if strings.HasPrefix(ev.SArgs[0], "GC ") && ev.SArgs[0] != "GC (idle)" {
|
||||
if flags&UtilBackground != 0 && strings.HasPrefix(ev.SArgs[0], "GC ") && ev.SArgs[0] != "GC (idle)" {
|
||||
// Background mark worker.
|
||||
bgMark[ev.G] = true
|
||||
gcPs++
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func TestMMUTrace(t *testing.T) {
|
|||
if err := p.Parse(0, 1<<62, nil); err != nil {
|
||||
t.Fatalf("failed to parse trace: %s", err)
|
||||
}
|
||||
mu := p.MutatorUtilization()
|
||||
mu := p.MutatorUtilization(UtilSTW | UtilBackground | UtilAssist)
|
||||
mmuCurve := NewMMUCurve(mu)
|
||||
|
||||
// Test the optimized implementation against the "obviously
|
||||
|
|
@ -106,7 +106,7 @@ func BenchmarkMMU(b *testing.B) {
|
|||
if err := p.Parse(0, 1<<62, nil); err != nil {
|
||||
b.Fatalf("failed to parse trace: %s", err)
|
||||
}
|
||||
mu := p.MutatorUtilization()
|
||||
mu := p.MutatorUtilization(UtilSTW | UtilBackground | UtilAssist | UtilSweep)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
|
|
|||
Loading…
Reference in New Issue