tiny.trace.Event
Defined in event.
API (28)
Actions
Public operations.
allocationboundaryBytescheckpointcheckpointRestorecloneAllocdeiniteqlForReplayfreefromJsonLinefunctionEnterfunctionExitsafepointReachedsessionEndsessionStartuserwriteJsonLine
Fields and members
Public fields and members.
alignmentdatafunction_idkindlabelobject_idoperationsite_idsizestack_map_idstatustimepoint
Source
Source: lib/trace/src/event.zig:85
zig
pub const Event = struct { kind: EventKind, timepoint: Timepoint, function_id: u64 = 0, site_id: u64 = 0, stack_map_id: u64 = 0, object_id: u64 = 0, size: u64 = 0, alignment: u32 = 0, status: i64 = 0, operation: ?[]const u8 = null, label: ?[]const u8 = null, data: ?[]const u8 = null, pub fn sessionStart(timepoint: Timepoint, label: []const u8) Event { return .{ .kind = .session_start, .timepoint = timepoint, .label = label }; } pub fn sessionEnd(timepoint: Timepoint, status: i64) Event { return .{ .kind = .session_end, .timepoint = timepoint, .status = status }; } pub fn functionEnter(timepoint: Timepoint, safepoint: Safepoint) Event { return functionEvent(.function_enter, timepoint, safepoint); } pub fn functionExit(timepoint: Timepoint, safepoint: Safepoint) Event { return functionEvent(.function_exit, timepoint, safepoint); } pub fn safepointReached(timepoint: Timepoint, safepoint: Safepoint) Event { return functionEvent(.safepoint, timepoint, safepoint); } pub fn boundaryBytes(timepoint: Timepoint, operation: []const u8, bytes: []const u8) Event { return .{ .kind = .boundary, .timepoint = timepoint, .operation = operation, .data = bytes, }; } pub fn allocation( timepoint: Timepoint, object_id: u64, size: u64, alignment: u32, label: ?[]const u8, ) Event { return .{ .kind = .allocation, .timepoint = timepoint, .object_id = object_id, .size = size, .alignment = alignment, .label = label, }; } pub fn free(timepoint: Timepoint, object_id: u64) Event { return .{ .kind = .free, .timepoint = timepoint, .object_id = object_id }; } pub fn checkpoint(timepoint: Timepoint, label: []const u8, bytes: []const u8) Event { return .{ .kind = .checkpoint, .timepoint = timepoint, .label = label, .data = bytes, }; } pub fn checkpointRestore(timepoint: Timepoint, label: []const u8) Event { return .{ .kind = .checkpoint_restore, .timepoint = timepoint, .label = label }; } pub fn user(timepoint: Timepoint, label: []const u8, bytes: []const u8) Event { return .{ .kind = .user, .timepoint = timepoint, .label = label, .data = bytes, }; } pub fn cloneAlloc(self: Event, allocator: Allocator) !Event { var cloned = self; cloned.operation = if (self.operation) |operation| try allocator.dupe(u8, operation) else null; errdefer if (cloned.operation) |operation| allocator.free(operation); cloned.label = if (self.label) |label| try allocator.dupe(u8, label) else null; errdefer if (cloned.label) |label| allocator.free(label); cloned.data = if (self.data) |data| try allocator.dupe(u8, data) else null; errdefer if (cloned.data) |data| allocator.free(data); return cloned; } pub fn deinit(self: *Event, allocator: Allocator) void { if (self.operation) |operation| allocator.free(operation); if (self.label) |label| allocator.free(label); if (self.data) |data| allocator.free(data); self.* = undefined; } pub fn eqlForReplay(left: Event, right: Event) bool { return left.kind == right.kind and Timepoint.eql(left.timepoint, right.timepoint) and left.function_id == right.function_id and left.site_id == right.site_id and left.stack_map_id == right.stack_map_id and left.object_id == right.object_id and left.size == right.size and left.alignment == right.alignment and left.status == right.status and optionalBytesEql(left.operation, right.operation) and optionalBytesEql(left.label, right.label) and optionalBytesEql(left.data, right.data); } pub fn writeJsonLine(self: Event, writer: *std.Io.Writer) !void { var stream = pretty_json.Writer.init(writer, .minified); const object = try stream.object(); try object.field("v", trace_format_version); const timepoint = try object.object("timepoint"); try timepoint.field("epoch", self.timepoint.epoch); try timepoint.field("thread", self.timepoint.thread_id); try timepoint.field("seq", self.timepoint.seq); try timepoint.end(); try object.field("kind", self.kind.tag()); try object.field("function_id", self.function_id); try object.field("site_id", self.site_id); try object.field("stack_map_id", self.stack_map_id); try object.field("object_id", self.object_id); try object.field("size", self.size); try object.field("alignment", self.alignment); try object.field("status", self.status); if (self.operation) |operation| try object.field("operation", operation); if (self.label) |label| try object.field("label", label); if (self.data) |data| try object.hexString("data_hex", data); try object.endLine(); } pub fn fromJsonLine(allocator: Allocator, line: []const u8) !Event { const parsed = std.json.parseFromSlice(std.json.Value, allocator, line, .{}) catch return error.InvalidEventJson; defer parsed.deinit(); const object = switch (parsed.value) { .object => |object| object, else => return error.InvalidEventJson, }; const version = try jsonU64(object.get("v") orelse return error.InvalidEventJson); if (version != trace_format_version) return error.UnsupportedTraceVersion; const timepoint_object = switch (object.get("timepoint") orelse return error.InvalidEventJson) { .object => |value| value, else => return error.InvalidEventJson, }; const kind_text = try jsonString(object.get("kind") orelse return error.InvalidEventJson); const kind = EventKind.fromTag(kind_text) orelse return error.InvalidEventJson; var event = Event{ .kind = kind, .timepoint = .{ .epoch = try jsonU64(timepoint_object.get("epoch") orelse return error.InvalidEventJson), .thread_id = @intCast(try jsonU64(timepoint_object.get("thread") orelse return error.InvalidEventJson)), .seq = try jsonU64(timepoint_object.get("seq") orelse return error.InvalidEventJson), }, .function_id = try jsonU64(object.get("function_id") orelse return error.InvalidEventJson), .site_id = try jsonU64(object.get("site_id") orelse return error.InvalidEventJson), .stack_map_id = try jsonU64(object.get("stack_map_id") orelse return error.InvalidEventJson), .object_id = try jsonU64(object.get("object_id") orelse return error.InvalidEventJson), .size = try jsonU64(object.get("size") orelse return error.InvalidEventJson), .alignment = @intCast(try jsonU64(object.get("alignment") orelse return error.InvalidEventJson)), .status = try jsonI64(object.get("status") orelse return error.InvalidEventJson), }; errdefer event.deinit(allocator); if (object.get("operation")) |operation| { event.operation = try allocator.dupe(u8, try jsonString(operation)); } if (object.get("label")) |label| { event.label = try allocator.dupe(u8, try jsonString(label)); } if (object.get("data_hex")) |data_hex| { event.data = try decodeHexAlloc(allocator, try jsonString(data_hex)); } return event; }};Source: lib/trace/src/root.zig:43
zig
pub const Event = event.Event;Complete caller list for Event.boundaryBytes
8 direct callers.
lib.trace.src.event.test_event_json_roundtrip_preserves_replay_identity[function] — test source atlib/trace/src/event.zig:377in nearest public ownertiny.trace.eventlib.trace.src.properties.store.drawEvent[function] — private source atlib/trace/src/properties/store.zig:122in nearest public ownerlib.trace.src.properties.storelib.trace.src.replay.test_summary_query_writes_trace-level_totals_as_jsonl[function] — test source atlib/trace/src/replay.zig:1171in nearest public ownertiny.trace.replaylib.trace.src.replay.test_thread_query_writes_per-thread_event_ranges_and_counts[function] — test source atlib/trace/src/replay.zig:1201in nearest public ownertiny.trace.replaytiny.trace.Session.boundaryBytesAlloc[method] atlib/trace/src/session.zig:127lib.trace.src.session.test_boundary_replay_copies_borrowed_bytes_before_advancing[function] — test source atlib/trace/src/session.zig:650in nearest public ownertiny.trace.sessionlib.trace.src.session.test_session_failure_atomicity_rejects_noncanonical_boundary_fields[function] — test source atlib/trace/src/session.zig:594in nearest public ownertiny.trace.sessionlib.trace.src.session.test_session_failure_atomicity_retries_boundary_replay_after_allocation_failure[function] — test source atlib/trace/src/session.zig:568in nearest public ownertiny.trace.session
Complete caller list for Event.functionEnter
7 direct callers.
lib.trace.src.properties.session.Action.expected[method] — private source atlib/trace/src/properties/session.zig:30in nearest public ownerlib.trace.src.properties.sessionlib.trace.src.properties.store.drawEvent[function] — private source atlib/trace/src/properties/store.zig:122in nearest public ownerlib.trace.src.properties.storelib.trace.src.replay.test_frame_query_drops_exited_frames_by_target_timepoint[function] — test source atlib/trace/src/replay.zig:1276in nearest public ownertiny.trace.replaylib.trace.src.replay.test_frame_query_ignores_other_threads[function] — test source atlib/trace/src/replay.zig:1303in nearest public ownertiny.trace.replaylib.trace.src.replay.test_frame_query_returns_active_stack_at_safepoint[function] — test source atlib/trace/src/replay.zig:1255in nearest public ownertiny.trace.replaylib.trace.src.replay.test_thread_query_writes_per-thread_event_ranges_and_counts[function] — test source atlib/trace/src/replay.zig:1201in nearest public ownertiny.trace.replaytiny.trace.Session.functionEnter[method] atlib/trace/src/session.zig:73
Complete caller list for Event.safepointReached
10 direct callers.
lib.trace.src.properties.session.Action.expected[method] — private source atlib/trace/src/properties/session.zig:30in nearest public ownerlib.trace.src.properties.sessionlib.trace.src.properties.store.drawEvent[function] — private source atlib/trace/src/properties/store.zig:122in nearest public ownerlib.trace.src.properties.storelib.trace.src.replay.test_frame_query_represents_safepoint-only_traces[function] — test source atlib/trace/src/replay.zig:1290in nearest public ownertiny.trace.replaylib.trace.src.replay.test_frame_query_returns_active_stack_at_safepoint[function] — test source atlib/trace/src/replay.zig:1255in nearest public ownertiny.trace.replaylib.trace.src.replay.test_object_query_writes_allocation_lifetimes_as_jsonl[function] — test source atlib/trace/src/replay.zig:1228in nearest public ownertiny.trace.replaylib.trace.src.replay.test_thread_query_writes_per-thread_event_ranges_and_counts[function] — test source atlib/trace/src/replay.zig:1201in nearest public ownertiny.trace.replaylib.trace.src.replay.test_timepoint_query_writes_compact_navigation_jsonl[function] — test source atlib/trace/src/replay.zig:943in nearest public ownertiny.trace.replaytiny.trace.Session.safepoint[method] atlib/trace/src/session.zig:91lib.trace.src.session.test_replay_mismatch_leaves_the_session_retryable[function] — test source atlib/trace/src/session.zig:632in nearest public ownertiny.trace.sessionlib.trace.src.session.test_replay_validates_a_borrowed_stream_and_exposes_numeric_progress[function] — test source atlib/trace/src/session.zig:525in nearest public ownertiny.trace.session
Complete caller list for Event.sessionStart
10 direct callers.
lib.trace.src.properties.session.Action.expected[method] — private source atlib/trace/src/properties/session.zig:30in nearest public ownerlib.trace.src.properties.sessionlib.trace.src.properties.store.drawEvent[function] — private source atlib/trace/src/properties/store.zig:122in nearest public ownerlib.trace.src.properties.storelib.trace.src.replay.test_summary_query_writes_trace-level_totals_as_jsonl[function] — test source atlib/trace/src/replay.zig:1171in nearest public ownertiny.trace.replaylib.trace.src.replay.test_thread_query_writes_per-thread_event_ranges_and_counts[function] — test source atlib/trace/src/replay.zig:1201in nearest public ownertiny.trace.replaylib.trace.src.replay.test_timepoint_query_writes_compact_navigation_jsonl[function] — test source atlib/trace/src/replay.zig:943in nearest public ownertiny.trace.replaytiny.trace.Session.sessionStart[method] atlib/trace/src/session.zig:55lib.trace.src.session.test_replay_validates_a_borrowed_stream_and_exposes_numeric_progress[function] — test source atlib/trace/src/session.zig:525in nearest public ownertiny.trace.sessionlib.trace.src.session.test_session_failure_atomicity_retries_a_failed_source_peek[function] — test source atlib/trace/src/session.zig:505in nearest public ownertiny.trace.sessionlib.trace.src.store.test.test_reader_refuses_an_unfinished_recording[function] — test source atlib/trace/src/store/test.zig:362in nearest public ownerlib.trace.src.store.testlib.trace.src.store.test.test_writer_rejects_an_unreadable_event_without_poisoning_the_trace[function] — test source atlib/trace/src/store/test.zig:206in nearest public ownerlib.trace.src.store.test
Complete caller list for Event.user
20 direct callers.
lib.choir.src.backends.gpu.metal.msl.writeMember[function] — private source atlib/choir/src/backends/gpu/metal/msl.zig:1355in nearest public ownertiny.choir.backends.gpu.metal.msllib.trace.src.properties.session.Action.expected[method] — private source atlib/trace/src/properties/session.zig:30in nearest public ownerlib.trace.src.properties.sessionlib.trace.src.properties.store.drawEvent[function] — private source atlib/trace/src/properties/store.zig:122in nearest public ownerlib.trace.src.properties.storelib.trace.src.replay.test_checkpoint_lookup_returns_nearest_predecessor[function] — test source atlib/trace/src/replay.zig:931in nearest public ownertiny.trace.replaylib.trace.src.replay.test_timepoint_query_writes_compact_navigation_jsonl[function] — test source atlib/trace/src/replay.zig:943in nearest public ownertiny.trace.replaylib.trace.src.replay.test_user_event_query_filters_labels_and_payload_protocols[function] — test source atlib/trace/src/replay.zig:962in nearest public ownertiny.trace.replaylib.trace.src.replay.test_user_event_stats_can_sort_by_mean_metric[function] — test source atlib/trace/src/replay.zig:1127in nearest public ownertiny.trace.replaylib.trace.src.replay.test_user_event_stats_groups_by_payload_and_sums_numeric_metrics[function] — test source atlib/trace/src/replay.zig:1071in nearest public ownertiny.trace.replaytiny.trace.Session.userEvent[method] atlib/trace/src/session.zig:210lib.trace.src.store.format.block.test_binary_event_block_rejects_truncation_and_trailing_bytes[function] — test source atlib/trace/src/store/format/block.zig:135in nearest public ownertiny.trace.store.format.blocklib.trace.src.store.format.block.test_binary_event_block_round_trips_bounded_records[function] — test source atlib/trace/src/store/format/block.zig:118in nearest public ownertiny.trace.store.format.blocklib.trace.src.store.format.codec.test_binary_event_codec_rejects_truncation_and_noncanonical_optionals[function] — test source atlib/trace/src/store/format/codec.zig:159in nearest public ownertiny.trace.store.format.codeclib.trace.src.store.reader.stream.test_reader_decode_failure_leaves_the_encoded_event_pending_for_retry[function] — test source atlib/trace/src/store/reader/stream.zig:301in nearest public ownerlib.trace.src.store.reader.streamlib.trace.src.store.reader.stream.test_reader_limit_failure_leaves_the_encoded_event_pending_for_retry[function] — test source atlib/trace/src/store/reader/stream.zig:313in nearest public ownerlib.trace.src.store.reader.streamlib.trace.src.store.reader.test.test_trace_reader_remains_allocator-independent_through_SQL_verification[function] — test source atlib/trace/src/store/reader/test.zig:16in nearest public ownerlib.trace.src.store.reader.testlib.trace.src.store.test.test_recording_append_has_bounded_allocation-free_steady_state[function] — test source atlib/trace/src/store/test.zig:231in nearest public ownerlib.trace.src.store.testlib.trace.src.store.test.test_writer_rejects_an_unreadable_event_without_poisoning_the_trace[function] — test source atlib/trace/src/store/test.zig:206in nearest public ownerlib.trace.src.store.testlib.trace.src.store.test.test_writer_reports_caller-selected_manifest_I/O_capacity[function] — test source atlib/trace/src/store/test.zig:161in nearest public ownerlib.trace.src.store.testlib.trace.src.store.test.writeFixture[function] — private source atlib/trace/src/store/test.zig:41in nearest public ownerlib.trace.src.store.testlib.trace.src.store.writer.test.test_trace_writer_remains_allocation-free_through_SQL_checkpoints_and_finish[function] — test source atlib/trace/src/store/writer/test.zig:56in nearest public ownerlib.trace.src.store.writer.test
Audit
| Definitions | 17 |
|---|---|
| Public names | 34 |
| Members | 12 |
| Version | 26.7.0 |
| Revision | daab053ee433 |