Documentation
¶
Overview ¶
Package unifiedtrace correlates Go runtime/trace events, signpost intervals, Metal GPU command buffer timestamps, and generic Perfetto counter/marker/span tracks onto a single monotonic Darwin nanosecond timeline with zero cgo.
All telemetry sources share Darwin's monotonic mach_absolute_time domain:
- MachClock reads mach_absolute_time, mach_continuous_time, and mach_timebase_info via purego, and measures the live continuous-to-absolute domain offset.
- Calibrator samples paired CPU and GPU timestamps via metal.MTLDeviceObject.SampleTimestampsGpuTimestamp and fits an ordinary least squares Calibration reporting slope, drift (ppm), monotonicity, max/RMS residuals, and sleep discontinuity detection (|Δ(MachContNS - MachAbsNS)| > 1ms).
- ParseGoTrace decodes Go execution trace v2 streams (EvFrequency and EvClockSnapshot) to extract STW GC pauses, GC cycles (including active mid-GC cycles from runtime/trace.FlightRecorder snapshots), GC mark assists, heap alloc/goal counters, sync/mutex lock waits, user tasks, and user regions in monotonic nanoseconds.
- Recorder captures a bounded start/stop window into a Timeline.
- Ring maintains fixed-capacity ring buffers with lazy rate-limited clock anchoring (zero background goroutines) and pairs with runtime/trace.FlightRecorder via Ring.Snapshot.
- Timeline computes overlap summaries (Timeline.Summarize), streams compact Chrome Trace Event JSON (Timeline.WriteChromeTrace) for Perfetto and chrome://tracing, and writes diagnostic bundles (WriteBundle).
Basic start/stop usage:
dev := metal.MTLCreateSystemDefaultDevice()
rec, err := unifiedtrace.NewRecorder(dev, nil)
if err != nil {
log.Fatal(err)
}
if err := rec.Start(); err != nil {
log.Fatal(err)
}
span := rec.BeginSignpost("step", nil)
commitNS := rec.Clock().AbsoluteNowNS()
cb.Commit()
cb.WaitUntilCompleted()
rec.RecordCommandBuffer("step", commitNS, cb, nil)
span.End()
tl, err := rec.Stop()
Continuous flight-recorder usage:
fr := trace.NewFlightRecorder(trace.FlightRecorderConfig{MinAge: 5 * time.Second})
fr.Start()
defer fr.Stop()
ring, err := unifiedtrace.NewRing(dev, unifiedtrace.RingOptions{})
// ... record spans, counters, markers, signposts, command buffers ...
tl, err := ring.Snapshot(fr)
err = unifiedtrace.WriteBundle(dir, tl, nil)
Example ¶
package main
import (
"fmt"
"log"
"github.com/tmc/apple/metal"
"github.com/tmc/apple/x/unifiedtrace"
)
func main() {
dev := metal.MTLCreateSystemDefaultDevice()
rec, err := unifiedtrace.NewRecorder(dev, nil)
if err != nil {
log.Fatal(err)
}
if err := rec.Start(); err != nil {
log.Fatal(err)
}
span := rec.BeginSignpost("work", nil)
// Encode and commit Metal work here, then call rec.RecordCommandBuffer.
span.End()
tl, err := rec.Stop()
if err != nil {
log.Fatal(err)
}
sum := tl.Summarize()
fmt.Printf("signposts=%d regions=%d\n", sum.SignpostCount, sum.UserRegionCount)
}
Output:
Index ¶
- func CFTimeToAbsNS(sec float64) uint64
- func IntervalOverlapNS(a0, a1, b0, b1 uint64) uint64
- func WriteBundle(dir string, tl *Timeline, extra map[string]io.WriterTo) error
- type Calibration
- type Calibrator
- type ChromeEvent
- type ChromeTrace
- type ClockAnchor
- type ClockSample
- type CounterSample
- type GPUEvent
- type GoTrace
- type MachClock
- type MarkerEvent
- type Recorder
- func (r *Recorder) BeginSignpost(name string, args map[string]any) *SignpostSpan
- func (r *Recorder) Calibrator() *Calibrator
- func (r *Recorder) Clock() *MachClock
- func (r *Recorder) RecordCommandBuffer(name string, commitNS uint64, cb metal.MTLCommandBuffer, args map[string]any) GPUEvent
- func (r *Recorder) RecordCounter(name string, tsNS uint64, values map[string]float64)
- func (r *Recorder) RecordGPUEvent(ev GPUEvent)
- func (r *Recorder) RecordMarker(name string, tsNS uint64, args map[string]any)
- func (r *Recorder) RecordSignpost(ev SignpostEvent)
- func (r *Recorder) RecordSpan(track, name string, startNS, endNS uint64, args map[string]any)
- func (r *Recorder) SampleClock() (ClockSample, error)
- func (r *Recorder) Start() error
- func (r *Recorder) Stop() (*Timeline, error)
- type Ring
- func (r *Ring) BeginSignpost(name string, args map[string]any) *SignpostSpan
- func (r *Ring) Clock() *MachClock
- func (r *Ring) RecordCommandBuffer(name string, commitNS uint64, cb metal.MTLCommandBuffer, args map[string]any) GPUEvent
- func (r *Ring) RecordCounter(name string, tsNS uint64, values map[string]float64)
- func (r *Ring) RecordGPUEvent(ev GPUEvent)
- func (r *Ring) RecordMarker(name string, tsNS uint64, args map[string]any)
- func (r *Ring) RecordSignpost(ev SignpostEvent)
- func (r *Ring) RecordSpan(track, name string, startNS, endNS uint64, args map[string]any)
- func (r *Ring) SampleClock() ClockSample
- func (r *Ring) Snapshot(goTrace io.WriterTo) (*Timeline, error)
- type RingOptions
- type SignpostEvent
- type SignpostSpan
- type SpanEvent
- type Summary
- type Timeline
- func (t *Timeline) ChromeTrace() ChromeTrace
- func (t *Timeline) GCOverlapNS(startNS, endNS uint64) uint64
- func (t *Timeline) RecordCounter(name string, tsNS uint64, values map[string]float64)
- func (t *Timeline) RecordMarker(name string, tsNS uint64, args map[string]any)
- func (t *Timeline) RecordSpan(track, name string, startNS, endNS uint64, args map[string]any)
- func (t *Timeline) STWOverlapNS(startNS, endNS uint64) uint64
- func (t *Timeline) Summarize() Summary
- func (t *Timeline) WriteChromeTrace(w io.Writer) error
- type TraceInterval
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CFTimeToAbsNS ¶
CFTimeToAbsNS converts a CoreFoundation / Metal CFTimeInterval (seconds on the mach_absolute_time domain) into integer nanoseconds.
func IntervalOverlapNS ¶
IntervalOverlapNS returns the nanosecond overlap of [a0, a1] and [b0, b1].
Example ¶
package main
import (
"fmt"
"github.com/tmc/apple/x/unifiedtrace"
)
func main() {
fmt.Println(unifiedtrace.IntervalOverlapNS(100, 250, 200, 400))
fmt.Println(unifiedtrace.IntervalOverlapNS(100, 200, 200, 300))
}
Output: 50 0
func WriteBundle ¶
WriteBundle writes a self-contained diagnostic bundle to dir:
- trace.out: raw Go execution trace bytes (when len(tl.RawGoTrace) > 0)
- timeline.json.gz: gzip-compressed compact Chrome Trace Event JSON
- any caller-supplied extra attachments (for example, "heap.pprof": pprof.Lookup("heap"))
Each key in extra must be a clean single-element filename with no directory separators or path traversal. Nil io.WriterTo values in extra are skipped.
Types ¶
type Calibration ¶
type Calibration struct {
Samples []ClockSample
RefGPUNS uint64
RefCPUNS uint64
Slope float64 // dimensionless; 1.0 indicates zero relative drift
InterceptNS float64 // residual intercept at RefGPUNS in nanoseconds
DriftPPM float64 // (Slope - 1) * 1e6
MaxResidualNS float64 // max |actual - predicted| across all samples
RMSResidualNS float64 // RMS residual across all samples
MonotonicCPU bool
MonotonicGPU bool
SleepDiscontinuity bool // true when |Δ(MachContNS - MachAbsNS)| > 1ms across samples
ClockDiscontinuityNS int64 // largest signed Δ(MachContNS - MachAbsNS) relative to the first sample
}
Calibration summarizes the ordinary least squares linear fit mapping GPU timestamps onto the CPU monotonic clock:
cpuNS ≈ Slope*(gpuNS - RefGPUNS) + RefCPUNS + InterceptNS
func FitCalibration ¶
func FitCalibration(samples []ClockSample) (Calibration, error)
FitCalibration fits an ordinary least squares line from GPU timestamps to CPU timestamps and computes monotonicity and residual statistics.
Example ¶
package main
import (
"fmt"
"log"
"github.com/tmc/apple/x/unifiedtrace"
)
func main() {
samples := []unifiedtrace.ClockSample{
{CPUNS: 1_000_000, GPUNS: 500_000},
{CPUNS: 2_000_000, GPUNS: 1_500_000},
{CPUNS: 3_000_000, GPUNS: 2_500_000},
}
cal, err := unifiedtrace.FitCalibration(samples)
if err != nil {
log.Fatal(err)
}
fmt.Printf("slope=%.3f drift=%.1fppm mapped=%d\n", cal.Slope, cal.DriftPPM, cal.GPUToCPUNS(2_000_000))
}
Output: slope=1.000 drift=0.0ppm mapped=2500000
func (Calibration) GPUToCPUNS ¶
func (c Calibration) GPUToCPUNS(gpuNS uint64) uint64
GPUToCPUNS maps a raw GPU timestamp (ns) onto the CPU monotonic clock (ns).
type Calibrator ¶
type Calibrator struct {
// contains filtered or unexported fields
}
Calibrator collects paired CPU/GPU clock samples from a Metal device and fits a monotonic Calibration. It is safe for concurrent use.
func NewCalibrator ¶
func NewCalibrator(device metal.MTLDeviceObject) (*Calibrator, error)
NewCalibrator returns a Calibrator for device using a Mach monotonic clock.
func (*Calibrator) Clock ¶
func (c *Calibrator) Clock() *MachClock
Clock returns the underlying monotonic Mach clock.
func (*Calibrator) Fit ¶
func (c *Calibrator) Fit() (Calibration, error)
Fit computes the linear Calibration over all samples collected so far.
func (*Calibrator) Sample ¶
func (c *Calibrator) Sample() ClockSample
Sample collects a single paired CPU/GPU timestamp sample via MTLDevice.SampleTimestampsGpuTimestamp bracketed by Mach clock reads.
func (*Calibrator) SampleN ¶
func (c *Calibrator) SampleN(n int, interval time.Duration) []ClockSample
SampleN collects n paired clock samples separated by interval.
func (*Calibrator) Samples ¶
func (c *Calibrator) Samples() []ClockSample
Samples returns a snapshot of all collected clock samples.
type ChromeEvent ¶
type ChromeEvent struct {
Name string `json:"name"`
Cat string `json:"cat,omitempty"`
Ph string `json:"ph"`
Scope string `json:"s,omitempty"`
TS float64 `json:"ts"`
Dur float64 `json:"dur,omitempty"`
PID int `json:"pid"`
TID int `json:"tid"`
Args map[string]any `json:"args,omitempty"`
}
ChromeEvent represents a single event in Chrome Trace Event JSON. Timestamps (TS) and durations (Dur) are in microseconds relative to t0.
type ChromeTrace ¶
type ChromeTrace struct {
DisplayTimeUnit string `json:"displayTimeUnit"`
TraceEvents []ChromeEvent `json:"traceEvents"`
}
ChromeTrace is the Chrome Trace Event Format (JSON Object Format) accepted by Perfetto (ui.perfetto.dev) and chrome://tracing.
type ClockAnchor ¶
type ClockAnchor struct {
TraceTS uint64 // raw trace clock ticks
MonoNS uint64 // Go runtime monotonic nanoseconds (mach_absolute_time on darwin)
WallSec uint64
WallNS uint64
}
ClockAnchor records an EvClockSnapshot from the Go execution trace.
type ClockSample ¶
type ClockSample struct {
CPUNS uint64 // CPU monotonic timestamp in nanoseconds
GPUNS uint64 // GPU timestamp in nanoseconds
MachAbsNS uint64 // Bracketed mach_absolute_time in nanoseconds
MachContNS uint64 // Bracketed mach_continuous_time in nanoseconds
}
ClockSample holds one paired CPU/GPU timestamp observation from MTLDevice.sampleTimestamps:gpuTimestamp: bracketed by Mach clock reads.
type CounterSample ¶
CounterSample records a named numeric counter series at a monotonic Mach timestamp. It is exported as a Chrome Trace "C" counter event.
type GPUEvent ¶
type GPUEvent struct {
Name string
CommitNS uint64
KernelStartNS uint64
KernelEndNS uint64
GPUStartNS uint64
GPUEndNS uint64
CompleteNS uint64
Args map[string]any
}
GPUEvent records Metal command buffer timestamps on the monotonic Mach clock.
type GoTrace ¶
type GoTrace struct {
Header string
FreqHz uint64
MinMonoNS uint64
MaxMonoNS uint64
Anchors []ClockAnchor
STWPauses []TraceInterval
GCCycles []TraceInterval
GCMarkAssists []TraceInterval
LockWaits []TraceInterval
UserRegions []TraceInterval
UserTasks []TraceInterval
HeapCounters []CounterSample
TotalEvents int
}
GoTrace holds correlated intervals extracted from a runtime/trace buffer.
func ParseGoTrace ¶
ParseGoTrace decodes a Go 1.25+ execution trace stream and maps STW pauses, GC cycles, sync/mutex lock waits, user tasks, and user regions onto the monotonic nanosecond clock using EvFrequency and EvClockSnapshot.
type MachClock ¶
type MachClock struct {
// contains filtered or unexported fields
}
MachClock reads Darwin's monotonic Mach clocks via purego with zero cgo. Both mach_absolute_time and mach_continuous_time advance at the same timebase frequency (numer/denom nanoseconds per tick); mach_continuous_time also advances across system sleep.
func NewMachClock ¶
NewMachClock resolves the Mach timebase symbols and queries mach_timebase_info.
func (*MachClock) AbsoluteNowNS ¶
AbsoluteNowNS returns mach_absolute_time converted to nanoseconds.
func (*MachClock) ContinuousNowNS ¶
ContinuousNowNS returns mach_continuous_time converted to nanoseconds.
func (*MachClock) ContinuousOffsetNS ¶
ContinuousOffsetNS measures (mach_continuous_time - mach_absolute_time) in ns using a bracketed read to minimize measurement skew.
type MarkerEvent ¶
MarkerEvent records a global instant marker at a monotonic Mach timestamp. It is exported as a Chrome Trace "i" instant event with scope "g".
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder captures Go runtime/trace, x/signpost intervals, and Metal GPU command buffer timestamps onto a unified monotonic timeline.
A Recorder is safe for concurrent use between Recorder.Start and Recorder.Stop.
func NewRecorder ¶
NewRecorder creates a Recorder for an optional Metal device and optional signpost.Logger. If device has a zero ID, GPU clock calibration is skipped and the recorder captures CPU runtime/trace and signpost events only. If sp is nil, a default PointsOfInterest logger is created.
func (*Recorder) BeginSignpost ¶
func (r *Recorder) BeginSignpost(name string, args map[string]any) *SignpostSpan
BeginSignpost emits an x/signpost interval begin and returns a SignpostSpan whose End method closes the interval and records it on the timeline.
func (*Recorder) Calibrator ¶
func (r *Recorder) Calibrator() *Calibrator
Calibrator returns the CPU/GPU clock calibrator, or nil if no Metal device was provided.
func (*Recorder) RecordCommandBuffer ¶
func (r *Recorder) RecordCommandBuffer(name string, commitNS uint64, cb metal.MTLCommandBuffer, args map[string]any) GPUEvent
RecordCommandBuffer extracts Metal kernel and GPU timestamps from a completed command buffer, associates them with commitNS, and appends a GPUEvent.
func (*Recorder) RecordCounter ¶
RecordCounter appends a counter sample at tsNS (or current mach_absolute_time if tsNS is 0). It is rendered as a Chrome Trace "C" counter event.
func (*Recorder) RecordGPUEvent ¶
RecordGPUEvent appends a pre-populated GPU event to the timeline.
func (*Recorder) RecordMarker ¶
RecordMarker appends a global instant marker at tsNS (or current mach_absolute_time if tsNS is 0). It is rendered as a Chrome Trace "i" event with scope "g".
func (*Recorder) RecordSignpost ¶
func (r *Recorder) RecordSignpost(ev SignpostEvent)
RecordSignpost appends a completed signpost event to the timeline.
func (*Recorder) RecordSpan ¶
RecordSpan appends a generic duration span on a named track. It is rendered as a Chrome Trace "X" complete event.
func (*Recorder) SampleClock ¶
func (r *Recorder) SampleClock() (ClockSample, error)
SampleClock records an additional paired CPU/GPU timestamp sample during a run.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring maintains bounded in-memory ring buffers of side-channel telemetry (signposts, GPU events, counters, markers, generic spans, and clock anchors) designed to pair with Go's runtime/trace.FlightRecorder.
Ring spawns no background goroutines. Clock samples are anchored lazily at most once per ClockAnchorInterval on Record calls and on Ring.Snapshot. A Ring is safe for concurrent use.
func NewRing ¶
func NewRing(device metal.MTLDeviceObject, opts RingOptions) (*Ring, error)
NewRing creates a bounded Ring for an optional Metal device. If device has a zero ID, GPU timestamp sampling is skipped and Mach clock anchors are still collected for sleep-discontinuity detection.
func (*Ring) BeginSignpost ¶
func (r *Ring) BeginSignpost(name string, args map[string]any) *SignpostSpan
BeginSignpost emits an x/signpost interval begin and returns a SignpostSpan whose End method records the completed interval into the ring.
func (*Ring) RecordCommandBuffer ¶
func (r *Ring) RecordCommandBuffer(name string, commitNS uint64, cb metal.MTLCommandBuffer, args map[string]any) GPUEvent
RecordCommandBuffer extracts Metal kernel and GPU timestamps from a completed command buffer and pushes a GPUEvent into the bounded ring.
func (*Ring) RecordCounter ¶
RecordCounter pushes a counter sample at tsNS (or current mach_absolute_time if tsNS is 0) into the bounded ring.
func (*Ring) RecordGPUEvent ¶
RecordGPUEvent pushes a pre-populated GPU event into the bounded ring.
func (*Ring) RecordMarker ¶
RecordMarker pushes a global instant marker at tsNS (or current mach_absolute_time if tsNS is 0) into the bounded ring.
func (*Ring) RecordSignpost ¶
func (r *Ring) RecordSignpost(ev SignpostEvent)
RecordSignpost pushes a completed signpost event into the bounded ring.
func (*Ring) RecordSpan ¶
RecordSpan pushes a generic duration span on a named track into the bounded ring.
func (*Ring) SampleClock ¶
func (r *Ring) SampleClock() ClockSample
SampleClock captures a paired CPU/GPU (when a Metal device is configured) and Mach absolute/continuous clock anchor and appends it to the bounded clock ring.
func (*Ring) Snapshot ¶
Snapshot captures goTrace (typically a *runtime/trace.FlightRecorder) into RawGoTrace, parses it to determine the monotonic window [minMonoNS, maxMonoNS], slices all side-event rings to that window, and fits an OLS Calibration over only the clock samples bracketing the snapshot window.
Snapshot is non-destructive and may be called repeatedly while recording continues.
type RingOptions ¶
type RingOptions struct {
MaxSpans int
MaxCounters int
MaxMarkers int
MaxSignposts int
MaxClockSamples int
ClockAnchorInterval time.Duration
Signpost *signpost.Logger // optional; nil uses default PointsOfInterest logger
}
RingOptions configures the fixed capacities and lazy clock anchoring interval of a Ring. Zero values select sensible defaults.
type SignpostEvent ¶
type SignpostEvent struct {
Name string
ID signpost.ID
StartNS uint64
EndNS uint64
Args map[string]any
}
SignpostEvent records one x/signpost interval on the monotonic Mach clock.
type SignpostSpan ¶
type SignpostSpan struct {
// contains filtered or unexported fields
}
SignpostSpan represents an in-flight signpost interval started by Recorder.BeginSignpost or Ring.BeginSignpost. Call SignpostSpan.End when the interval completes.
func (*SignpostSpan) End ¶
func (s *SignpostSpan) End() SignpostEvent
End emits the matching signpost interval end and records the completed SignpostEvent onto the recorder's timeline. Calling End more than once is a no-op and returns the previously recorded event.
func (*SignpostSpan) StartNS ¶
func (s *SignpostSpan) StartNS() uint64
StartNS returns the monotonic start timestamp of the span in nanoseconds.
type SpanEvent ¶
SpanEvent records a generic duration span on a named track (for external telemetry sources such as x/metalcounters, x/ane, or x/rdma). It is exported as a Chrome Trace "X" complete event.
type Summary ¶
type Summary struct {
WallNS uint64
GPUExecNS uint64
GPUQueueWaitNS int64 // signed sum of (GPUStartNS - CommitNS) to expose sub-µs skew
STWPauseNS uint64
STWOverlapGPUNS uint64
STWCount int
GCCycleCount int
MarkAssistCount int
LockWaitCount int
UserRegionCount int
UserTaskCount int
SignpostCount int
GPUEventCount int
CounterCount int
MarkerCount int
SpanCount int
}
Summary aggregates global duration, overlap, and event counts for a Timeline.
type Timeline ¶
type Timeline struct {
DeviceName string
StartNS uint64
EndNS uint64
ContinuousOffsetNS int64
Calibration Calibration
GoTrace *GoTrace
RawGoTrace []byte
Signposts []SignpostEvent
GPUEvents []GPUEvent
Counters []CounterSample
Markers []MarkerEvent
Spans []SpanEvent
}
Timeline holds the correlated Go runtime/trace, x/signpost, Metal GPU, and generic track telemetry from a single recording window on Darwin's monotonic Mach clock.
func (*Timeline) ChromeTrace ¶
func (t *Timeline) ChromeTrace() ChromeTrace
ChromeTrace projects all correlated sources in t onto a single Chrome Trace Event document anchored at the earliest observed timestamp.
func (*Timeline) GCOverlapNS ¶
GCOverlapNS returns the total nanosecond overlap between [startNS, endNS] and all GC cycles recorded in t.
func (*Timeline) RecordCounter ¶
RecordCounter appends a counter sample to t.
func (*Timeline) RecordMarker ¶
RecordMarker appends a global instant marker to t.
func (*Timeline) RecordSpan ¶
RecordSpan appends a generic duration span on a named track to t.
Example ¶
package main
import (
"fmt"
"github.com/tmc/apple/x/unifiedtrace"
)
func main() {
tl := &unifiedtrace.Timeline{StartNS: 1_000, EndNS: 5_000}
tl.RecordCounter("thermal", 1_500, map[string]float64{"level": 1})
tl.RecordMarker("trigger", 2_000, map[string]any{"reason": "p99_spike"})
tl.RecordSpan("ane", "eval", 2_500, 4_000, map[string]any{"layer": 0})
sum := tl.Summarize()
fmt.Printf("counters=%d markers=%d spans=%d\n", sum.CounterCount, sum.MarkerCount, sum.SpanCount)
}
Output: counters=1 markers=1 spans=1
func (*Timeline) STWOverlapNS ¶
STWOverlapNS returns the total nanosecond overlap between [startNS, endNS] and all stop-the-world GC pauses recorded in t.
func (*Timeline) Summarize ¶
Summarize computes aggregate durations, GPU execution overlap with Go STW pauses, and event counts across all correlated sources.
func (*Timeline) WriteChromeTrace ¶
WriteChromeTrace streams compact Chrome Trace Event JSON directly to w without materializing a full event slice. Callers may pass a gzip.Writer to compress the stream on the fly.
Example ¶
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"github.com/tmc/apple/x/unifiedtrace"
)
func main() {
tl := &unifiedtrace.Timeline{
DeviceName: "Apple GPU",
StartNS: 1_000,
EndNS: 5_000,
Signposts: []unifiedtrace.SignpostEvent{
{Name: "encode", StartNS: 1_500, EndNS: 2_500},
},
GPUEvents: []unifiedtrace.GPUEvent{
{Name: "step[0]", CommitNS: 2_500, GPUStartNS: 3_000, GPUEndNS: 4_500},
},
}
var buf bytes.Buffer
if err := tl.WriteChromeTrace(&buf); err != nil {
log.Fatal(err)
}
var ct unifiedtrace.ChromeTrace
if err := json.Unmarshal(buf.Bytes(), &ct); err != nil {
log.Fatal(err)
}
fmt.Printf("unit=%s events=%d\n", ct.DisplayTimeUnit, len(ct.TraceEvents))
}
Output: unit=ns events=15
type TraceInterval ¶
type TraceInterval struct {
Kind string // "stw", "gc", "lock-wait", "region", "task"
Name string
G uint64 // goroutine ID (0 if global)
TaskID uint64
StartNS uint64
EndNS uint64
}
TraceInterval is a decoded interval from runtime/trace projected onto the unified monotonic nanosecond clock (mach_absolute_time ns on darwin).