unified-trace

command
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

unified-trace

A zero-cgo, zero-entitlement Metal + Go timeline correlation demo built on github.com/tmc/apple/x/unifiedtrace. It projects three independent telemetry sources onto a single monotonic Darwin nanosecond clock (mach_absolute_time / mach_continuous_time):

  1. Go runtime/trace — goroutine sync/mutex lock waits, GC cycles, stop-the-world (STW) pauses, trace.NewTask, and trace.WithRegion intervals, decoded directly from the Go trace v2 wire format (EvFrequency + EvClockSnapshot anchor).
  2. x/signpost — os_signpost intervals (PointsOfInterest) emitted via purego and bracketed with Mach monotonic timestamps.
  3. Metal GPU timestamps — MTLCommandBuffer.GPUStartTime / GPUEndTime / KernelStartTime / KernelEndTime, calibrated against MTLDevice.SampleTimestamps (ordinary least squares CPU↔GPU clock fit with drift and residual reporting).

Usage

Run with CGO_ENABLED=0:

CGO_ENABLED=0 go run ./examples/gpu/unified-trace

Export a Chrome Trace Event JSON file viewable in Perfetto or chrome://tracing (and optionally the raw Go execution trace for go tool trace):

CGO_ENABLED=0 go run ./examples/gpu/unified-trace \
  -steps 12 \
  -trace-out /tmp/unified-trace.json \
  -gotrace-out /tmp/go-trace.out

Run tests:

CGO_ENABLED=0 go test -v ./x/unifiedtrace ./examples/gpu/unified-trace
Flags
Flag Default Description
-steps 12 Number of synthetic decode steps
-elements 1048576 float32 elements per Metal compute dispatch
-iters 64 Inner FMA iterations per GPU thread
-trace-out "" Output path for Chrome Trace Event JSON
-gotrace-out "" Optional output path for raw Go runtime/trace binary

Files

  • workload.go — synthetic Metal compute decode loop instrumented with x/unifiedtrace.Recorder, runtime/trace, evalMu lock contention, and GC pressure.
  • timeline.go — per-step breakdown and tabular summary formatting using unifiedtrace.Timeline.
  • main.go — CLI entrypoint.
  • main_test.go — live Metal + Go trace + signpost correlation and Chrome trace JSON validation test.

Documentation

Rendered for darwin/amd64

Overview

Command unified-trace correlates Go runtime/trace (goroutines, GC STW pauses, lock waits, user regions), x/signpost intervals, and Metal GPU timestamps calibrated via MTLDevice.SampleTimestamps onto a single monotonic Mach clock using github.com/tmc/apple/x/unifiedtrace with zero cgo.

Jump to

Keyboard shortcuts

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