reid41 / QA-Pilot

QA-Pilot is an interactive chat project that leverages online/local LLM for rapid understanding and navigation of GitHub code repository.
Apache License 2.0
165 stars 17 forks source link

generics in Go codegraph #66

Open reid41 opened 3 months ago

reid41 commented 3 months ago

Generics in Go, so far cannot make a associate with below situation:

src/cmd/trace/gstate.go

type gState[R resource] struct {
    baseName  string
    named     bool   // Whether baseName has been set.
    label     string // EventLabel extension.
    isSystemG bool

    executing R // The resource this goroutine is executing on. (Could be itself.)
.....
}

func (gs *gState[R]) setStartCause(ts trace.Time, name string, resource uint64, stack trace.Stack) {
    gs.startCause.time = ts
    gs.startCause.name = name
    gs.startCause.resource = resource
    gs.startCause.stack = stack
}

// created indicates that this goroutine was just created by the provided creator.
func (gs *gState[R]) created(ts trace.Time, creator R, stack trace.Stack) {
    if creator == R(noResource) {
        return
    }
    gs.setStartCause(ts, "go", uint64(creator), stack)
}

// start indicates that a goroutine has started running on a proc.
func (gs *gState[R]) start(ts trace.Time, resource R, ctx *traceContext) {
    // Set the time for all the active ranges.
    for name := range gs.activeRanges {
        gs.activeRanges[name] = activeRange{ts, trace.NoStack}
    }

    if gs.startCause.name != "" {
        // It has a start cause. Emit a flow event.
        ctx.Arrow(traceviewer.ArrowEvent{
            Name:         gs.startCause.name,
            Start:        ctx.elapsed(gs.startCause.time),
            End:          ctx.elapsed(ts),
            FromResource: uint64(gs.startCause.resource),
            ToResource:   uint64(resource),
            FromStack:    ctx.Stack(viewerFrames(gs.startCause.stack)),
        })
        gs.startCause.time = 0
        gs.startCause.name = ""
        gs.startCause.resource = 0
        gs.startCause.stack = trace.NoStack
    }
    gs.executing = resource
    gs.startRunningTime = ts
}