internal

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegionFlagShared = 0x1
)

Variables

This section is empty.

Functions

func FindStackSubmatchIndex

func FindStackSubmatchIndex(stk []*trace.Frame, specs ...string) []int

FindStackSubmatchIndex searches stk for subexpressions described in specs. It returns a slice of offsets in groups of three. The first element in each group is number of leaf frames skipped before finding the subexpression. The next two elements are the start and end byte offsets within that frame's function name.

func HasStackRe

func HasStackRe(stk []*trace.Frame, specs ...string) bool

func TrimVendor

func TrimVendor(fn string) string

func Uncovered

func Uncovered(parent TimeSpan, children ...TimeSpan) time.Duration

Uncovered calculates how much of the parent range is not covered by at least one of the ranges that its children cover.

Types

type Data

type Data struct {
	// Result holds the event list from a basic execution trace parse result.
	// The events are chronological order.
	Events []*trace.Event
	// GoroutineEvents maps each observed goroutine to that goroutine's events.
	GoroutineEvents map[uint64][]*trace.Event
	// GoroutineList lists all known goroutines by ID
	GoroutineList []uint64
	// Backlinks holds events that are the targets of other events' Link field.
	Backlinks map[*trace.Event]*trace.Event
	// GoroutineRuns maps GoStart events to the sequence of events on that
	// goroutine that followed, until the goroutine stopped running.
	GoroutineRuns map[*trace.Event][]*trace.Event

	// Prev maps an event to the preceding event on the same goroutine.
	Prev map[*trace.Event]*trace.Event
	// Next maps an event to the subsequent event on the same goroutine.
	Next map[*trace.Event]*trace.Event
}

func PrepareData

func PrepareData(events []*trace.Event) *Data

type EventList

type EventList []*trace.Event

func (EventList) BlockNet

func (list EventList) BlockNet() []TimeSpan

func (EventList) Extent

func (list EventList) Extent() TimeSpan

func (EventList) Running

func (list EventList) Running() []TimeSpan

type GeneralTracker

type GeneralTracker struct {
	// Activate returns whether the event marks the start of a new Region.
	Activate func(ev *trace.Event) bool
	// Keepalive returns whether the event indicates the Region is still active.
	Keepalive func(ev *trace.Event) bool
	// Critical returns whether the event is a critical part of the Region
	// lifecycle. Events that are not critical to a Region's lifecycle are
	// trimmed from the end.
	Critical func(ev *trace.Event) bool
	// Reactivate controls whether the GeneralTracker finds the largest or
	// smallest possible Regions. When true, the GeneralTracker will try to
	// start a new Region for any Event that matches the Activate function. When
	// false, it tries to add Events to an existing Region.
	Reactivate bool

	// AllowSingle enables single-event Regions. Otherwise, the smallest
	// possible Region is 2 events.
	AllowSingle bool

	// FlushAtEnd attempts to write out any partial Region at the goroutine's
	// final Event.
	FlushAtEnd bool

	Verbose bool

	// Flush is called with the Events that make up a single Region.
	Flush func([]*trace.Event)
	// contains filtered or unexported fields
}

func (*GeneralTracker) Process

func (t *GeneralTracker) Process(evs []*trace.Event)

type ProcessRegionConnectionsInput

type ProcessRegionConnectionsInput struct {
	Data    *Data
	Regions []*Region
}

type ProcessRegionConnectionsResult

type ProcessRegionConnectionsResult struct {
	EventRegionStacks map[*trace.Event]*RegionStack
}

type Region

type Region struct {
	Kind   string
	Flags  int64
	Events []*trace.Event
}

A Region is a contiguous series of Events on a single goroutine to accomplish a particular goal.

func (*Region) Shared

func (r *Region) Shared() bool

Shared returns whether the Region represents work that will be shared with unrelated goroutines.

type RegionConnector

type RegionConnector struct {
	// StartRegion sets the new RegionStack of a goroutine when it starts a new
	// local Region. If left unset, the RegionConnector uses a default behavior
	// of adding the starting RegionStack on top of the existing RegionStack.
	StartRegion func(ev *trace.Event, existing, starting *RegionStack) *RegionStack
	// ApplyOnWake sets the new RegionStack for a goroutine when it is made
	// runnable by another goroutine's event ev. The GoStart event for the
	// now-runnable goroutine is ev.Link. If left unset, the RegionConnector
	// uses a default behavior of trimming the inbound RegionStack back to
	ApplyOnWake func(ev *trace.Event, existing, inbound *RegionStack) *RegionStack
}

func (*RegionConnector) DoApplyOnWake

func (rc *RegionConnector) DoApplyOnWake(ev *trace.Event, existing, inbound *RegionStack) *RegionStack

func (*RegionConnector) DoStartRegion

func (rc *RegionConnector) DoStartRegion(ev *trace.Event, existing, starting *RegionStack) *RegionStack

type RegionStack

type RegionStack struct {
	// Start marks when this goroutine began the current explanation for its
	// work.
	Start *trace.Event
	// Local is a Region on this goroutine that explains its current work. If
	// this goroutine is working on behalf of another and does not have an
	// annotation for its own work, this field will be nil.
	Local *Region
	// Parent links to the higher-level reason for the current work.
	Parent *RegionStack
}

A RegionStack is an immutable linked list of Regions and inbound communication events that explain why the program is currently doing a unit of work.

func (*RegionStack) DebugString

func (rs *RegionStack) DebugString() string

type StackFlag

type StackFlag struct {
	Event byte
	Specs []string
}

func (*StackFlag) EventMatches

func (sf *StackFlag) EventMatches(t byte) bool

func (*StackFlag) Set

func (sf *StackFlag) Set(v string) error

func (*StackFlag) String

func (sf *StackFlag) String() string

type Task

type Task struct {
	Region   *Region
	Children []*Task
}

A Task is a set of Regions (across any number of goroutines) that work together to accomplish a particular goal.

type TimeSpan

type TimeSpan [2]time.Duration

func Extent

func Extent(ts ...TimeSpan) TimeSpan

func (TimeSpan) End

func (ts TimeSpan) End() time.Duration

func (TimeSpan) Length

func (ts TimeSpan) Length() time.Duration

func (TimeSpan) Start

func (ts TimeSpan) Start() time.Duration

type TrackerState

type TrackerState func(*trace.Event) TrackerState

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL