signpostmsg

package
v0.6.19 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 1 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.

Documentation

Overview

Package signpostmsg emits os_signpost intervals that carry a formatted message under a small fixed set of names.

It is a constrained layer over github.com/tmc/apple/x/signpost: Instruments groups intervals by name and shows the message as detail, so a small fixed set of names with a descriptive message is usually the better shape for profiling: it yields one track per name rather than one per span.

The names are Model, Layer and Op, matching the conventional split of a compute pipeline into inference passes, block boundaries and individual dispatches. Pass the specific identity in the message:

log := signpostmsg.New("com.example.app", signpostmsg.PointsOfInterest)
id := log.NewID()
log.IntervalBegin(id, signpostmsg.Layer, "TransformerBlock_0")
// ... work ...
log.IntervalEnd(id, signpostmsg.Layer, "TransformerBlock_0")

Messages are emitted as public, so they are not redacted in trace output.

When built without cgo, this package delivers the message through github.com/tmc/apple/x/signpost, which constructs the "%{public}s" argument buffer directly. The message decodes in trace output when the format string is pooled in the binary's __TEXT,__oslogstring section — automatic under cgo, via a .syso otherwise (see x/signpost's pool.go). On non-Darwin platforms all operations are no-ops.

Index

Constants

View Source
const (
	// PointsOfInterest is the category Instruments displays in the Points of
	// Interest track.
	PointsOfInterest = "PointsOfInterest"
	// DynamicTracing is a category whose signposts are disabled until a tool
	// such as Instruments enables them.
	DynamicTracing = "DynamicTracing"
)

Category names understood by Instruments and the logging system. They mirror the constants in github.com/tmc/apple/x/signpost.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID uint64

ID identifies a signpost so that a begin can be paired with its end. The zero value is not usable; obtain one from Logger.NewID.

const IDExclusive ID = ID(signpost.IDExclusive)

IDExclusive is a shared id usable when at most one interval with a given name is in flight at a time on a log.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger emits signposts against a single os_log handle. The message is delivered as a public formatted argument ("%{public}s"), matching the cgo implementation, via signpost.Logger.IntervalBeginMessage and friends.

func New

func New(subsystem, category string) *Logger

New returns a Logger that emits signposts under the given subsystem and category. New never returns nil.

func (*Logger) Enabled

func (l *Logger) Enabled() bool

Enabled reports whether signposts are being recorded for this log.

func (*Logger) Event

func (l *Logger) Event(id ID, name Name, msg string)

Event emits a single point-in-time signpost tagged with name and carrying msg.

func (*Logger) IntervalBegin

func (l *Logger) IntervalBegin(id ID, name Name, msg string)

IntervalBegin marks the start of an interval identified by id, tagged with name and carrying msg. Pair it with an Logger.IntervalEnd call using the same id, name and msg.

func (*Logger) IntervalEnd

func (l *Logger) IntervalEnd(id ID, name Name, msg string)

IntervalEnd marks the end of the interval begun with the same id, name and msg.

func (*Logger) NewID

func (l *Logger) NewID() ID

NewID returns an ID that is unique among signposts logged to this Logger.

type Name

type Name int

Name identifies a signpost. The os_signpost macros require the name to be a compile-time literal, so the set of names is fixed; pass the varying part of a span's identity as the message.

const (
	// Model marks a high-level pass, such as one generation step.
	Model Name = iota
	// Layer marks a block boundary within a pass.
	Layer
	// Op marks a single compute dispatch.
	Op
)

func (Name) String

func (n Name) String() string

String returns the name as it appears in trace output.

Jump to

Keyboard shortcuts

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