telemetry

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package telemetry provides diagnostic and performance measurement types for the Apple Neural Engine.

Telemetry fields may return zeros on production hardware. Many ANE performance counters and diagnostic selectors are gated by ANEDevicePropertyIsInternalBuild in the IOKit registry. Each struct field has a Known bool that distinguishes "unavailable" from "zero": if Known is false, the underlying selector was not available.

Use [EvalWithStats] to collect hardware execution time and performance counters after evaluation. Use [ProbeDiagnostics] to inspect model queue depth, program state, and async request counts. Use [ProbeClientInfo], [ProbeCacheInfo], and [Snapshot] to capture the host environment.

All telemetry types have an Available method that reports whether any data was collected, and a ReportMetrics method that emits available data to a testing.B-compatible reporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerfCounterPlaceholder

func PerfCounterPlaceholder() string

PerfCounterPlaceholder returns the firmware placeholder sentinel string.

func SanitizeMetricName

func SanitizeMetricName(name string) string

SanitizeMetricName normalizes a raw firmware counter name into a stable, parseable metric name suitable for benchmark output. It lowercases the input, replaces non-alphanumeric characters with hyphens, collapses runs of hyphens, and trims leading/trailing hyphens.

Types

type CacheInfo

type CacheInfo struct {
	CacheDir      string
	CacheDirKnown bool
}

CacheInfo describes the ANE model cache.

func (CacheInfo) Available

func (ci CacheInfo) Available() bool

Available reports whether the cache directory was resolved.

type ClientInfo

type ClientInfo struct {
	NumANEs                         uint32
	NumANEsKnown                    bool
	NumCores                        uint32
	NumCoresKnown                   bool
	ArchitectureStr                 string
	ArchitectureStrKnown            bool
	BoardType                       int64
	BoardTypeKnown                  bool
	CapabilityMask                  uint64
	CapabilityMaskKnown             bool
	DataInterfaceVersion            uint64
	DataInterfaceVersionKnown       bool
	PrecompiledBinarySupported      bool
	PrecompiledBinarySupportedKnown bool
}

ClientInfo describes the ANE client connection capabilities.

func (ClientInfo) Available

func (ci ClientInfo) Available() bool

Available reports whether any Known field is true.

type ClientSnapshot added in v0.3.0

type ClientSnapshot struct {
	Device ane.DeviceInfo
	Client ClientInfo
	Cache  CacheInfo
}

ClientSnapshot captures the host and ANE environment at a point in time.

func (ClientSnapshot) Available added in v0.3.0

func (s ClientSnapshot) Available() bool

Available reports whether any component snapshot has data.

func (ClientSnapshot) ReportMetrics added in v0.3.0

func (s ClientSnapshot) ReportMetrics(b interface{ ReportMetric(float64, string) })

ReportMetrics reports the runtime environment to a testing.B-compatible reporter.

func (ClientSnapshot) String added in v0.3.0

func (s ClientSnapshot) String() string

String returns a compact human-readable summary of the runtime snapshot.

type Diagnostics

type Diagnostics struct {
	ModelQueueDepth      int
	ModelQueueDepthKnown bool
	ProgramClass         string
	ProgramClassKnown    bool

	AsyncRequestsInFlight      int64
	AsyncRequestsInFlightKnown bool
	ProgramQueueDepth          int
	ProgramQueueDepthKnown     bool
	ProgramHandle              uint64
	ProgramHandleKnown         bool
	ModelState                 uint64
	ModelStateKnown            bool
}

Diagnostics contains best-effort runtime diagnostic information about a kernel.

func (Diagnostics) Available

func (d Diagnostics) Available() bool

Available reports whether any diagnostic field was probed.

func (Diagnostics) ReportMetrics

func (d Diagnostics) ReportMetrics(b interface{ ReportMetric(float64, string) })

ReportMetrics reports diagnostic state to a testing.B-compatible reporter.

func (Diagnostics) String

func (d Diagnostics) String() string

String returns a compact human-readable summary of the diagnostics.

type EvalStats

type EvalStats struct {
	HWExecutionNS         uint64        // hardware execution time in nanoseconds
	PerfCounterData       []byte        // raw bytes from perfStats.PerfCounterData()
	RawStatsData          []byte        // raw bytes from perfStats.PStatsRawData()
	PerfCounters          []PerfCounter // parsed named counters
	PerfCountersTruncated bool          // true if counter list was capped
	PerfStatsEntries      int           // number of entries in the PerfStatsArray (one per procedure)
}

EvalStats contains hardware performance statistics from an evaluation.

func (EvalStats) Available

func (s EvalStats) Available() bool

Available reports whether any hardware stats data was populated.

func (EvalStats) ReportMetrics

func (s EvalStats) ReportMetrics(b interface{ ReportMetric(float64, string) })

ReportMetrics reports evaluation statistics to a testing.B-compatible reporter.

func (EvalStats) String

func (s EvalStats) String() string

String returns a compact human-readable summary of the evaluation stats.

type EvalTelemetry

type EvalTelemetry struct {
	Stats       EvalStats
	Diagnostics Diagnostics
	Timing      EventTiming // zero unless set by caller after shared-event eval
}

EvalTelemetry bundles post-evaluation telemetry from a kernel.

func (EvalTelemetry) Available

func (t EvalTelemetry) Available() bool

Available reports whether any telemetry component has data.

func (EvalTelemetry) ReportMetrics

func (t EvalTelemetry) ReportMetrics(b interface{ ReportMetric(float64, string) })

ReportMetrics reports all available telemetry to a testing.B-compatible reporter.

func (EvalTelemetry) String

func (t EvalTelemetry) String() string

String returns a compact human-readable summary of the telemetry bundle.

type EventTiming

type EventTiming struct {
	EnqueueNS int64 // CPU wall-clock cost to submit the evaluation
	TotalNS   int64 // same as EnqueueNS for synchronous evals
}

EventTiming contains timing measurements from a shared event evaluation.

func (EventTiming) Available

func (t EventTiming) Available() bool

Available reports whether timing data was collected.

func (EventTiming) ReportMetrics

func (t EventTiming) ReportMetrics(b interface{ ReportMetric(float64, string) })

ReportMetrics reports event timing to a testing.B-compatible reporter.

func (EventTiming) String

func (t EventTiming) String() string

String returns a compact human-readable summary of the timing.

type PerfCounter

type PerfCounter struct {
	Index int
	Name  string
	Value uint64
}

PerfCounter represents a named hardware performance counter from an evaluation.

Jump to

Keyboard shortcuts

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