Table of Contents

Class PerTickSnapshotEventCodec

Namespace
Typhon.Profiler
Assembly
Typhon.Profiler.dll

Wire-format codec for the PerTickSnapshot record — packed bundle of gauge values emitted at tick boundary.

public static class PerTickSnapshotEventCodec
Inheritance
PerTickSnapshotEventCodec
Inherited Members

Remarks

Layout after the 12-byte common header:

offset 12..15  u32  TickNumber
offset 16..17  u16  FieldCount
offset 18..21  u32  Flags            // reserved; writers emit 0
offset 22+     repeated {u16 gaugeId; u8 valueKind; [4 or 8 B] value}

Records are variable-size. Callers pre-compute required bytes via ComputeSize(ReadOnlySpan<GaugeValue>) before claiming ring space, then hand the exact-sized span to WritePerTickSnapshot(Span<byte>, byte, long, uint, uint, ReadOnlySpan<GaugeValue>, out int). A ref-struct incremental builder will be added in Phase 1 for the in-ring emit path; this codec is phase-0 infrastructure for scratch-buffer round-trip tests and the decoder.

Fields

PrefixSize

Fixed prefix size: 12 B common header + 4 B tickNumber + 2 B fieldCount + 4 B flags = 22 B.

public const int PrefixSize = 22

Field Value

int

Methods

ComputeSize(ReadOnlySpan<GaugeValue>)

Compute the exact on-wire size of a snapshot carrying the given gauge values.

public static int ComputeSize(ReadOnlySpan<GaugeValue> values)

Parameters

values ReadOnlySpan<GaugeValue>

Returns

int

DecodePerTickSnapshot(ReadOnlySpan<byte>)

Decode a PerTickSnapshot record from source.

public static PerTickSnapshotData DecodePerTickSnapshot(ReadOnlySpan<byte> source)

Parameters

source ReadOnlySpan<byte>

Returns

PerTickSnapshotData

WritePerTickSnapshot(Span<byte>, byte, long, uint, uint, ReadOnlySpan<GaugeValue>, out int)

Encode a PerTickSnapshot record into destination. The span must be at least ComputeSize(ReadOnlySpan<GaugeValue>) bytes long. values length must fit in a u16 (65,535 fields — far beyond any realistic snapshot).

public static void WritePerTickSnapshot(Span<byte> destination, byte threadSlot, long timestamp, uint tickNumber, uint flags, ReadOnlySpan<GaugeValue> values, out int bytesWritten)

Parameters

destination Span<byte>
threadSlot byte
timestamp long
tickNumber uint
flags uint
values ReadOnlySpan<GaugeValue>
bytesWritten int