mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #104211 from MikeSpreitzer/stackmore
Increase debug logging in waitGroupCounter::Add
This commit is contained in:
commit
f610eee161
@ -18,8 +18,10 @@ package eventclock
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"container/heap"
|
"container/heap"
|
||||||
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -43,24 +45,54 @@ var _ counter.GoRoutineCounter = (*waitGroupCounter)(nil)
|
|||||||
|
|
||||||
func (wgc *waitGroupCounter) Add(delta int) {
|
func (wgc *waitGroupCounter) Add(delta int) {
|
||||||
if klog.V(7).Enabled() {
|
if klog.V(7).Enabled() {
|
||||||
var pcs [5]uintptr
|
var pcs [10]uintptr
|
||||||
nCallers := runtime.Callers(2, pcs[:])
|
nCallers := runtime.Callers(2, pcs[:])
|
||||||
frames := runtime.CallersFrames(pcs[:nCallers])
|
frames := runtime.CallersFrames(pcs[:nCallers])
|
||||||
frame1, more1 := frames.Next()
|
callers := make(stackExcerpt, 0, 10)
|
||||||
fileParts1 := strings.Split(frame1.File, "/")
|
more := frames != nil
|
||||||
tail2 := "(none)"
|
boundary := 1
|
||||||
line2 := 0
|
for i := 0; more && len(callers) < cap(callers); i++ {
|
||||||
if more1 {
|
var frame runtime.Frame
|
||||||
frame2, _ := frames.Next()
|
frame, more = frames.Next()
|
||||||
fileParts2 := strings.Split(frame2.File, "/")
|
fileParts := strings.Split(frame.File, "/")
|
||||||
tail2 = fileParts2[len(fileParts2)-1]
|
isMine := strings.HasSuffix(frame.File, "/fairqueuing/eventclock/testing/fake.go")
|
||||||
line2 = frame2.Line
|
if isMine {
|
||||||
|
boundary = 2
|
||||||
}
|
}
|
||||||
klog.Infof("GRC(%p).Add(%d) from %s:%d from %s:%d", wgc, delta, fileParts1[len(fileParts1)-1], frame1.Line, tail2, line2)
|
callers = append(callers, stackFrame{file: fileParts[len(fileParts)-1], line: frame.Line})
|
||||||
|
if i >= boundary && !isMine {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
klog.InfoS("Add", "counter", fmt.Sprintf("%p", wgc), "delta", delta, "callers", callers)
|
||||||
}
|
}
|
||||||
wgc.wg.Add(delta)
|
wgc.wg.Add(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type stackExcerpt []stackFrame
|
||||||
|
|
||||||
|
type stackFrame struct {
|
||||||
|
file string
|
||||||
|
line int
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ fmt.Stringer = stackExcerpt(nil)
|
||||||
|
|
||||||
|
func (se stackExcerpt) String() string {
|
||||||
|
var sb strings.Builder
|
||||||
|
sb.WriteString("[")
|
||||||
|
for i, sf := range se {
|
||||||
|
if i > 0 {
|
||||||
|
sb.WriteString(", ")
|
||||||
|
}
|
||||||
|
sb.WriteString(sf.file)
|
||||||
|
sb.WriteString(":")
|
||||||
|
sb.WriteString(strconv.FormatInt(int64(sf.line), 10))
|
||||||
|
}
|
||||||
|
sb.WriteString("]")
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (wgc *waitGroupCounter) Wait() {
|
func (wgc *waitGroupCounter) Wait() {
|
||||||
wgc.wg.Wait()
|
wgc.wg.Wait()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user