Help us shape the future of Go! Take the 2026 Go Developer Survey

decode

package
v0.1.61 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EventAlloc = "alloc"
View Source
const EventCPU = "cpu"
View Source
const EventLock = "lock"
View Source
const (
	// EventPark is a thread parked, as by LockSupport.park.
	EventPark = "park"
)

The events a profile's samples are of.

View Source
const EventWall = "wall"
View Source
const UnitBytes = "bytes"
View Source
const (
	UnitNanos = "ns"
)

The units a sample's Value is in.

View Source
const UnitSamples = "samples"

Variables

This section is empty.

Functions

This section is empty.

Types

type DecodeOptions

type DecodeOptions struct {
	// After is the watermark: only events that end after it are decoded, so
	// a dump of the whole recording so far yields only what it added.
	After time.Time
	// Threads splits each stack's samples by the thread they were taken on.
	Threads bool
	// MaxStackDepth keeps only the leaf-most frames of deeper stacks; zero
	// keeps every frame.
	MaxStackDepth int
}

DecodeOptions say which of a recording's events Decode keeps and how it aggregates them.

type Profile

type Profile struct {
	Samples []StackSample
	Counts  map[string]int64
	// From and Latest are the earliest and latest end of the events decoded;
	// both are zero when no event ended after DecodeOptions.After.
	From, Latest time.Time
}

Profile is what Decode read from a recording: a Sample per event, thread (when split by thread) and stack, the samples of each event, and the window of the events it decoded.

func Decode

func Decode(data []byte, options DecodeOptions) (profile Profile, err error)

Decode reads the profiling events of a JFR recording, as the JDK's Flight Recorder or async-profiler writes it, one or more chunks long: execution and wall-clock samples, allocations, monitor waits and parks. It refuses an empty or malformed recording, and a stack, frame or thread its chunk's constant pool does not hold.

type StackSample

type StackSample struct {
	// Timestamp is the end of the dump's window: the latest event it added.
	Timestamp time.Time `json:"timestamp" pretty:"label=At" sort:"timestamp"`
	// From is the start of the dump's window: the earliest event it added.
	From   time.Time `json:"from" pretty:"hide"`
	Event  string    `json:"event" filter:"terms"`
	Thread string    `json:"thread,omitempty" filter:"terms"`
	// Frame is the stack's leaf, the frame the event happened in.
	Frame string `json:"frame" pretty:"label=Top frame" filter:"text"`
	// Stack is the collapsed stack, root first: frames joined by ";", headed
	// by "[truncated]" when the recorder or MaxStackDepth cut its root side.
	Stack   string `json:"stack" pretty:"hide" filter:"text"`
	Samples int64  `json:"samples" sort:"samples"`
	// Value is the samples' weight in Unit: their count for cpu and wall,
	// the bytes allocated for alloc, the time blocked for lock and park.
	Value int64  `json:"value" sort:"value"`
	Unit  string `json:"unit"`
}

StackSample is one stack's share of a dump: the samples of one event that ended on that stack, on one thread when a capture splits them by thread, within the window a dump added to the recording.

Jump to

Keyboard shortcuts

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