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 ¶
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 ¶
New returns a Logger that emits signposts under the given subsystem and category. New never returns nil.
func (*Logger) Event ¶
Event emits a single point-in-time signpost tagged with name and carrying msg.
func (*Logger) IntervalBegin ¶
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 ¶
IntervalEnd marks the end of the interval begun with the same id, name and msg.