package trace
Import Path
internal/trace (on go.dev)
Dependency Relation
imports 16 packages, and imported by 0 packages
Package-Level Type Names (total 11)
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
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
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 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)
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
UtilFlags controls the behavior of MutatorUtilization.
func MutatorUtilization(events []*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 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 Read, Write, Reset, or 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 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 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 ReadRune.
If the most recent read or write operation on the buffer was
not a successful ReadRune, UnreadRune returns an error. (In this regard
it is stricter than 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 9)
GoroutineStats generates statistics for all goroutines in the trace.
func IsSystemGoroutine(entryFn string) bool
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.
NewMMUCurve returns an MMU curve for the given mutator utilization
function.
Parse parses, post-processes and verifies the trace.
Print dumps events to stdout. For debugging.
PrintEvent dumps the event to stdout. For debugging.
RelatedGoroutines finds a set of goroutines related to goroutine goid.
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.
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.
![]() |
The pages are generated with Golds v0.6.6. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |