package trace

Import Path
	internal/trace (on go.dev)

Dependency Relation
	imports 17 packages, and imported by one package


Package-Level Type Names (total 17)
/* sort by: | */
Event describes one event in the trace. // event-type-specific arguments // G on which the event happened linked event (can be nil), depends on event type: for GCStart: the GCStop for GCSTWStart: the GCSTWDone for GCSweepStart: the GCSweepDone for GoCreate: first GoStart of the created goroutine for GoStart/GoStartLabel: the associated GoEnd, GoBlock or other blocking event for GoSched/GoPreempt: the next GoStart for GoBlock and other blocking events: the unblock event for GoUnblock: the associated GoStart for blocking GoSysCall: the associated GoSysExit for GoSysExit: the next GoStart for GCMarkAssistStart: the associated GCMarkAssistDone for UserTaskCreate: the UserTaskEnd for UserRegion: if the start region, the corresponding UserRegion end event // offset in input file (for debugging and error reporting) // P on which the event happened (can be one of TimerP, NetpollP, SyscallP) // event-type-specific string args // stack trace (can be empty) // unique stack ID // timestamp in nanoseconds // one of Ev* (*Event) String() string *Event : expvar.Var *Event : fmt.Stringer func GoroutineStats(events []*Event) map[uint64]*GDesc func MutatorUtilization(events []*Event, flags UtilFlags) [][]MutatorUtil func Print(events []*Event) func PrintEvent(ev *Event) func RelatedGoroutines(events []*Event, goid uint64) map[uint64]bool
Frame is a frame in stack traces. File string Fn string Line int PC uint64 func internal/trace/traceviewer.(*Emitter).Stack(stk []*Frame) int
GDesc contains statistics and execution details of a single goroutine. CreationTime int64 EndTime int64 Statistics of execution time during the goroutine execution. GExecutionStat.BlockTime int64 GExecutionStat.ExecTime int64 GExecutionStat.GCTime int64 GExecutionStat.IOTime int64 GExecutionStat.SchedWaitTime int64 GExecutionStat.SweepTime int64 GExecutionStat.SyscallTime int64 GExecutionStat.TotalTime int64 ID uint64 Name string PC uint64 List of regions in the goroutine, sorted based on the start time. StartTime int64 func GoroutineStats(events []*Event) map[uint64]*GDesc
GExecutionStat contains statistics about a goroutine's execution during a period of time. BlockTime int64 ExecTime int64 GCTime int64 IOTime int64 SchedWaitTime int64 SweepTime int64 SyscallTime int64 TotalTime int64
GoroutineExecStats contains statistics about a goroutine's execution during a period of time. BlockTimeByReason map[string]time.Duration These stats are all non-overlapping. Total time the goroutine spent in certain ranges; may overlap with other stats. SchedWaitTime time.Duration SyscallBlockTime time.Duration SyscallTime time.Duration TotalTime is the duration of the goroutine's presence in the trace. Necessarily overlaps with other stats. ( GoroutineExecStats) NonOverlappingStats() map[string]time.Duration UnknownTime returns whatever isn't accounted for in TotalTime.
GoroutineSummary contains statistics and execution details of a single goroutine. (For v2 traces.) // Timestamp of the first appearance in the trace. // Timestamp of when the goroutine exited. 0 if the goroutine never exited. Statistics of execution time during the goroutine execution. GoroutineExecStats.BlockTimeByReason map[string]time.Duration These stats are all non-overlapping. Total time the goroutine spent in certain ranges; may overlap with other stats. GoroutineExecStats.SchedWaitTime time.Duration GoroutineExecStats.SyscallBlockTime time.Duration GoroutineExecStats.SyscallTime time.Duration TotalTime is the duration of the goroutine's presence in the trace. Necessarily overlaps with other stats. ID tracev2.GoID // A non-unique human-friendly identifier for the goroutine. // The first PC we saw for the entry function of the goroutine List of regions in the goroutine, sorted based on the start time. // Timestamp of the first time it started running. 0 if the goroutine never ran. ( GoroutineSummary) NonOverlappingStats() map[string]time.Duration UnknownTime returns whatever isn't accounted for in TotalTime.
An MMUCurve is the minimum mutator utilization curve across multiple window sizes. Examples returns n specific examples of the lowest mutator utilization for the given window size. The returned windows will be disjoint (otherwise there would be a huge number of mostly-overlapping windows at the single lowest point). There are no guarantees on which set of disjoint windows this returns. MMU returns the minimum mutator utilization for the given time window. This is the minimum utilization for all windows of this duration across the execution. The returned value is in the range [0, 1]. MUD returns mutator utilization distribution quantiles for the given window size. The mutator utilization distribution is the distribution of mean mutator utilization across all windows of the given window size in the trace. The minimum mutator utilization is the minimum (0th percentile) of this distribution. (However, if only the minimum is desired, it's more efficient to use the MMU method.) func NewMMUCurve(utils [][]MutatorUtil) *MMUCurve
MutatorUtil is a change in mutator utilization at a particular time. Mutator utilization functions are represented as a time-ordered []MutatorUtil. Time int64 Util is the mean mutator utilization starting at Time. This is in the range [0, 1]. func MutatorUtilization(events []*Event, flags UtilFlags) [][]MutatorUtil func MutatorUtilizationV2(events []tracev2.Event, flags UtilFlags) [][]MutatorUtil func NewMMUCurve(utils [][]MutatorUtil) *MMUCurve
ParseResult is the result of Parse. Events is the sorted list of Events in the trace. Stacks is the stack traces keyed by stack IDs from the trace. func Parse(r io.Reader, bin string) (ParseResult, error)
Summarizer constructs per-goroutine time statistics for v2 traces. Event feeds a single event into the stats summarizer. Finalize indicates to the summarizer that we're done processing the trace. It cleans up any remaining state and returns the full summary. func NewSummarizer() *Summarizer
Summary is the analysis result produced by the summarizer. Goroutines map[tracev2.GoID]*GoroutineSummary Tasks map[tracev2.TaskID]*UserTaskSummary func (*Summarizer).Finalize() *Summary
UserRegionDesc represents a region and goroutine execution stats while the region was active. Region end event. Normally EvUserRegion end event or nil, but can be EvGoStop or EvGoEnd event if the goroutine terminated without explicitly ending the region. GExecutionStat GExecutionStat GExecutionStat.BlockTime int64 GExecutionStat.ExecTime int64 GExecutionStat.GCTime int64 GExecutionStat.IOTime int64 GExecutionStat.SchedWaitTime int64 GExecutionStat.SweepTime int64 GExecutionStat.SyscallTime int64 GExecutionStat.TotalTime int64 Name string Region start event. Normally EvUserRegion start event or nil, but can be EvGoCreate event if the region is a synthetic region representing task inheritance from the parent goroutine. TaskID uint64
UserRegionSummary represents a region and goroutine execution stats while the region was active. (For v2 traces.) Region end event. Normally EventRegionEnd event or nil, but can be a state transition event to NotExist if the goroutine terminated without explicitly ending the region. GoroutineExecStats GoroutineExecStats GoroutineExecStats.BlockTimeByReason map[string]time.Duration These stats are all non-overlapping. Total time the goroutine spent in certain ranges; may overlap with other stats. GoroutineExecStats.SchedWaitTime time.Duration GoroutineExecStats.SyscallBlockTime time.Duration GoroutineExecStats.SyscallTime time.Duration TotalTime is the duration of the goroutine's presence in the trace. Necessarily overlaps with other stats. Name string Region start event. Normally EventRegionBegin event or nil, but can be a state transition event from NotExist or Undetermined if the region is a synthetic region representing task inheritance from the parent goroutine. TaskID tracev2.TaskID ( UserRegionSummary) NonOverlappingStats() map[string]time.Duration UnknownTime returns whatever isn't accounted for in TotalTime.
UserTaskSummary represents a task in the trace. Children []*UserTaskSummary End end event. Normally EventTaskEnd event or nil. Goroutines is the set of goroutines associated with this task. ID tracev2.TaskID Logs is a list of tracev2.EventLog events associated with the task. Name string // nil if the parent is unknown. List of regions in the task, sorted based on the start time. Task begin event. An EventTaskBegin event or nil. Complete returns true if we have complete information about the task from the trace: both a start and an end. Descendents returns a slice consisting of itself (always the first task returned), and the transitive closure of all of its children. func (*UserTaskSummary).Descendents() []*UserTaskSummary
UtilFlags controls the behavior of MutatorUtilization. func MutatorUtilization(events []*Event, flags UtilFlags) [][]MutatorUtil func MutatorUtilizationV2(events []tracev2.Event, flags UtilFlags) [][]MutatorUtil const UtilAssist const UtilBackground const UtilPerProc const UtilSTW const UtilSweep
UtilWindow is a specific window at Time. MutatorUtil is the mean mutator utilization in this window. Time int64 func (*MMUCurve).Examples(window time.Duration, n int) (worst []UtilWindow)
Writer is a test trace writer. Buffer bytes.Buffer Available returns how many bytes are unused in the buffer. AvailableBuffer returns an empty buffer with b.Available() capacity. This buffer is intended to be appended to and passed to an immediately succeeding [Buffer.Write] call. The buffer is only valid until the next write operation on b. Bytes returns a slice of length b.Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification (that is, only until the next call to a method like [Buffer.Read], [Buffer.Write], [Buffer.Reset], or [Buffer.Truncate]). The slice aliases the buffer content at least until the next buffer modification, so immediate changes to the slice will affect the result of future reads. Cap returns the capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data. Emit writes an event record to the trace. See Event types for valid types and required arguments. Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with [ErrTooLarge]. Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()). Next returns a slice containing the next n bytes from the buffer, advancing the buffer as if the bytes had been returned by [Buffer.Read]. If there are fewer than n bytes in the buffer, Next returns the entire buffer. The slice is only valid until the next call to a read or write method. Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil. ReadByte reads and returns the next byte from the buffer. If no byte is available, it returns error io.EOF. ReadBytes reads until the first occurrence of delim in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadBytes returns err != nil if and only if the returned data does not end in delim. ReadFrom reads data from r until EOF and appends it to the buffer, growing the buffer as needed. The return value n is the number of bytes read. Any error except io.EOF encountered during the read is also returned. If the buffer becomes too large, ReadFrom will panic with [ErrTooLarge]. ReadRune reads and returns the next UTF-8-encoded Unicode code point from the buffer. If no bytes are available, the error returned is io.EOF. If the bytes are an erroneous UTF-8 encoding, it consumes one byte and returns U+FFFD, 1. ReadString reads until the first occurrence of delim in the input, returning a string containing the data up to and including the delimiter. If ReadString encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadString returns err != nil if and only if the returned data does not end in delim. Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes. Reset is the same as [Buffer.Truncate](0). String returns the contents of the unread portion of the buffer as a string. If the [Buffer] is a nil pointer, it returns "<nil>". To build strings more efficiently, see the strings.Builder type. Truncate discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It panics if n is negative or greater than the length of the buffer. UnreadByte unreads the last byte returned by the most recent successful read operation that read at least one byte. If a write has happened since the last read, if the last read returned an error, or if the read read zero bytes, UnreadByte returns an error. UnreadRune unreads the last rune returned by [Buffer.ReadRune]. If the most recent read or write operation on the buffer was not a successful [Buffer.ReadRune], UnreadRune returns an error. (In this regard it is stricter than [Buffer.UnreadByte], which will unread the last byte from any read operation.) Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with [ErrTooLarge]. WriteByte appends the byte c to the buffer, growing the buffer as needed. The returned error is always nil, but is included to match [bufio.Writer]'s WriteByte. If the buffer becomes too large, WriteByte will panic with [ErrTooLarge]. WriteRune appends the UTF-8 encoding of Unicode code point r to the buffer, returning its length and an error, which is always nil but is included to match [bufio.Writer]'s WriteRune. The buffer is grown as needed; if it becomes too large, WriteRune will panic with [ErrTooLarge]. WriteString appends the contents of s to the buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with [ErrTooLarge]. WriteTo writes data to w until the buffer is drained or an error occurs. The return value n is the number of bytes written; it always fits into an int, but it is int64 to match the io.WriterTo interface. Any error encountered during the write is also returned. *Writer : internal/bisect.Writer *Writer : compress/flate.Reader *Writer : expvar.Var *Writer : fmt.Stringer *Writer : image/jpeg.Reader *Writer : io.ByteReader *Writer : io.ByteScanner *Writer : io.ByteWriter *Writer : io.Reader *Writer : io.ReaderFrom *Writer : io.ReadWriter *Writer : io.RuneReader *Writer : io.RuneScanner *Writer : io.StringWriter *Writer : io.Writer *Writer : io.WriterTo func NewWriter() *Writer
Package-Level Functions (total 13)
GoroutineStats generates statistics for all goroutines in the trace.
MutatorUtilization returns a set of mutator utilization functions for the given trace. Each function will always end with 0 utilization. The bounds of each function are implicit in the first and last event; outside of these bounds each function is undefined. If the UtilPerProc flag is not given, this always returns a single utilization function. Otherwise, it returns one function per P.
MutatorUtilizationV2 returns a set of mutator utilization functions for the given v2 trace, passed as an io.Reader. Each function will always end with 0 utilization. The bounds of each function are implicit in the first and last event; outside of these bounds each function is undefined. If the UtilPerProc flag is not given, this always returns a single utilization function. Otherwise, it returns one function per P.
NewMMUCurve returns an MMU curve for the given mutator utilization function.
NewSummarizer creates a new struct to build goroutine stats from a trace.
func NewWriter() *Writer
Parse parses, post-processes and verifies the trace.
Print dumps events to stdout. For debugging.
PrintEvent dumps the event to stdout. For debugging.
func ReadVersion(r io.Reader) (ver int, off int, err error)
RelatedGoroutines finds a set of goroutines related to goroutine goid.
RelatedGoroutinesV2 finds a set of goroutines related to goroutine goid for v2 traces. The association is based on whether they have synchronized with each other in the Go scheduler (one has unblocked another).
Package-Level Variables (total 3)
BreakTimestampsForTesting causes the parser to randomly alter timestamps (for testing of broken cputicks).
ErrTimeOrder is returned by Parse when the trace contains time stamps that do not respect actual event ordering.
var EventDescriptions [50]struct{Name string; minVersion int; Stack bool; Args []string; SArgs []string}
Package-Level Constants (total 62)
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Event types in the trace. Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
Special P identifiers:
const GCP = 1000004 // depicts GC state
const NetpollP = 1000002 // depicts network unblocks
const ProfileP = 1000005 // depicts recording of CPU profile samples
const SyscallP = 1000003 // depicts returns from syscalls
const TimerP = 1000001 // depicts timer unblocks
UtilAssist means utilization should account for mark assists.
UtilBackground means utilization should account for background mark workers.
UtilPerProc means each P should be given a separate utilization function. Otherwise, there is a single function and each P is given a fraction of the utilization.
UtilSTW means utilization should account for STW events. This includes non-GC STW events, which are typically user-requested.
UtilSweep means utilization should account for sweeping.