tiny.profiling.host
Defined in tiny.profiling.
API (29)
Actions
Public operations.
Options.anyOptions.buildArgsOptions.kindOptions.probeRequestOptions.requiresDirectOptions.toolOptions.validatemissingBinaryproberesetCaptureArtifactssetupFailedsummarizewarmupFailedwrap
Types and contracts
Public types and contracts.
Namespaces
Public namespaces.
Values and defaults
Public values and defaults.
Source
Source: src/profiling/host/runtime.zig:113
pub const Capture = struct { kind: []const u8, tool: []const u8, tool_version: ?[]const u8 = null, scope: []const u8 = scope, capture_path: []const u8, summary_path: []const u8, state: []const u8, caveat_kind: ?[]const u8 = null, caveat_message: ?[]const u8 = null,};Source: src/profiling/host/runtime.zig:130
pub const Lane = union(enum) { counters: counters.Lane, sampling: sampling.Lane, dhat: dhat.Lane, offcpu: offcpu.Lane, coverage: coverage.Lane,};Source: src/profiling/host/runtime.zig:27
pub const Options = struct { counters: ?counters.Options = null, sampling: ?sampling.Options = null, dhat: ?dhat.Options = null, offcpu: ?offcpu.Options = null, coverage: ?coverage.Options = null, pub fn validate(self: Options) !void { var enabled: usize = 0; if (self.counters != null) enabled += 1; if (self.sampling != null) enabled += 1; if (self.dhat != null) enabled += 1; if (self.offcpu != null) enabled += 1; if (self.coverage != null) enabled += 1; if (enabled > 1) return error.ConflictingHostProfilers; if (self.counters) |options| try options.validate(); if (self.sampling) |options| try options.validate(); } pub fn any(self: Options) bool { return self.counters != null or self.sampling != null or self.dhat != null or self.offcpu != null or self.coverage != null; } pub fn requiresDirect(self: Options) bool { return self.dhat != null or self.offcpu != null or self.coverage != null; } pub fn tool(self: Options) ?[]const u8 { if (self.counters != null) return counters.tool; if (self.sampling != null) return sampling.tool; if (self.dhat != null) return dhat.tool; if (self.offcpu) |options| return options.toolName(); if (self.coverage != null) return coverage.tool; return null; } pub fn kind(self: Options) ?[]const u8 { if (self.counters != null) return counters.kind; if (self.sampling != null) return sampling.kind; if (self.dhat != null) return dhat.kind; if (self.offcpu != null) return offcpu.kind; if (self.coverage != null) return coverage.kind; return null; } pub fn probeRequest( self: Options, allocator: std.mem.Allocator, ) !?ProbeRequest { if (self.counters != null or self.sampling != null or self.dhat != null or self.coverage != null) { return .{ .argv = try allocator.dupe( []const u8, &.{ self.tool().?, "--version" }, ), .version_output = true, }; } if (self.offcpu) |options| { const probe_flag = switch (options.mode) { .time => "-h", .stacks => "--version", }; return .{ .argv = try allocator.dupe( []const u8, &.{ options.toolName(), probe_flag }, ), .version_output = options.mode == .stacks, }; } return null; } pub fn buildArgs(self: Options) []const []const u8 { if (self.dhat != null and builtin.cpu.arch == .x86_64) { return &.{"-Dcpu=x86_64_v3"}; } return &.{}; }};Source: src/profiling/host/runtime.zig:17
pub const ProbeRequest = struct { argv: []const []const u8, version_output: bool,};Source: src/profiling/host/runtime.zig:22
pub const ToolProbe = struct { available: bool = false, version: ?[]const u8 = null,};Source: src/profiling/host/runtime.zig:125
pub const Wrapped = struct { argv: []const []const u8, lane: ?Lane = null,};Source: src/profiling/host/runtime.zig:13
pub const direct_scope = "workload-binary";Source: src/profiling/host/runtime.zig:300
pub fn missingBinary( allocator: std.mem.Allocator, options: Options, workload_root: []const u8, tool_probe: ToolProbe,) ![]const Capture { const lane = try descriptor(allocator, options, workload_root) orelse return &.{}; const rows = try allocator.alloc(Capture, 1); rows[0] = .{ .kind = lane.kind, .tool = lane.tool, .tool_version = tool_probe.version, .capture_path = lane.capture_path, .summary_path = lane.summary_path, .state = "binary_missing", .caveat_kind = "no_direct_binary", .caveat_message = "workload declares no benchmark binary in the catalog; direct-binary evidence needs bin metadata", }; return rows;}Source: src/profiling/host/runtime.zig:365
pub fn probe( allocator: std.mem.Allocator, process_io: std.Io, request: ProbeRequest,) !ToolProbe { const result = sys.process.run(allocator, process_io, .{ .argv = request.argv, .stdout_limit = .limited(max_probe_output_bytes), .stderr_limit = .limited(max_probe_output_bytes), }) catch |err| switch (err) { error.OutOfMemory => return err, else => return .{}, }; defer allocator.free(result.stdout); defer allocator.free(result.stderr); if (sys.process.exitCode(result.term) != 0) return .{}; return .{ .available = true, .version = if (request.version_output) try probeVersion(allocator, result.stdout, result.stderr) else null, };}Source: src/profiling/host/runtime.zig:174
pub fn resetCaptureArtifacts(wrapped: Wrapped) !void { const lane = wrapped.lane orelse return; switch (lane) { .counters => |value| { try deleteFileIfPresent(value.csv_path); for (value.runs) |run| try deleteFileIfPresent(run.csv_path); for (value.repetition_csv_paths) |path| try deleteFileIfPresent(path); for (value.event_groups) |group| try deleteFileIfPresent(group.csv_path); }, .sampling => |value| try deleteFileIfPresent(value.data_path), .dhat => |value| { try deleteFileIfPresent(value.capture_path); try deleteFileIfPresent(value.out_path); }, .offcpu => |value| { try deleteFileIfPresent(value.capture_path); try deleteFileIfPresent(value.diagnostics_path); }, .coverage => |value| try sys.fs.deleteTree(value.directory_path), }}Source: src/profiling/host/runtime.zig:12
pub const scope = "whole-step";Source: src/profiling/host/runtime.zig:321
pub fn setupFailed( allocator: std.mem.Allocator, options: Options, workload_root: []const u8, tool_probe: ToolProbe,) ![]const Capture { const lane = try descriptor(allocator, options, workload_root) orelse return &.{}; const rows = try allocator.alloc(Capture, 1); rows[0] = .{ .kind = lane.kind, .tool = lane.tool, .tool_version = tool_probe.version, .scope = direct_scope, .capture_path = lane.capture_path, .summary_path = lane.summary_path, .state = "setup_failed", .caveat_kind = "workload_build_failed", .caveat_message = "the benchmark binary failed to build; inspect setup stderr before interpreting missing evidence", }; return rows;}Source: src/profiling/host/runtime.zig:210
pub fn summarize( allocator: std.mem.Allocator, process_io: std.Io, wrapped: Wrapped, exit_code: i64, stderr_path: []const u8, tool_probe: ToolProbe, scope_label: []const u8, workload_name: []const u8, max_benchmark_allocated_bytes: ?u64,) ![]const Capture { const lane = wrapped.lane orelse return &.{}; var row = switch (lane) { .counters => |value| try counters.summarize( allocator, value, exit_code, stderr_path, tool_probe.available, ), .sampling => |value| try sampling.summarize( allocator, process_io, value, exit_code, stderr_path, tool_probe.available, ), .dhat => |value| try dhat.summarize( allocator, value, exit_code, stderr_path, tool_probe.available, max_benchmark_allocated_bytes, ), .offcpu => |value| try offcpu.summarize( allocator, value, exit_code, stderr_path, tool_probe.available, ), .coverage => |value| try coverage.summarize( allocator, value, exit_code, stderr_path, tool_probe.available, workload_name, ), }; row.tool_version = tool_probe.version; row.scope = scope_label; const rows = try allocator.alloc(Capture, 1); rows[0] = row; return rows;}Source: src/profiling/host/runtime.zig:343
pub fn warmupFailed( allocator: std.mem.Allocator, options: Options, workload_root: []const u8, tool_probe: ToolProbe,) ![]const Capture { const lane = try descriptor(allocator, options, workload_root) orelse return &.{}; const rows = try allocator.alloc(Capture, 1); rows[0] = .{ .kind = lane.kind, .tool = lane.tool, .tool_version = tool_probe.version, .scope = direct_scope, .capture_path = lane.capture_path, .summary_path = lane.summary_path, .state = "warmup_failed", .caveat_kind = "workload_warmup_failed", .caveat_message = "an unmeasured warmup failed; measurement and profiler capture were suppressed", }; return rows;}Source: src/profiling/host/runtime.zig:138
pub fn wrap( allocator: std.mem.Allocator, options: Options, argv: []const []const u8, workload_root: []const u8, tool_available: bool,) !Wrapped { try options.validate(); if (options.counters) |lane_options| { const lane = try counters.plan(allocator, lane_options, workload_root); if (!tool_available) return .{ .argv = argv, .lane = .{ .counters = lane } }; return .{ .argv = try counters.wrapArgv(allocator, lane_options, argv, lane), .lane = .{ .counters = lane } }; } if (options.sampling) |lane_options| { const lane = try sampling.plan(allocator, lane_options, workload_root); if (!tool_available) return .{ .argv = argv, .lane = .{ .sampling = lane } }; return .{ .argv = try sampling.wrapArgv(allocator, lane_options, argv, lane), .lane = .{ .sampling = lane } }; } if (options.dhat) |lane_options| { const lane = try dhat.plan(allocator, lane_options, workload_root); if (!tool_available) return .{ .argv = argv, .lane = .{ .dhat = lane } }; return .{ .argv = try dhat.wrapArgv(allocator, lane_options, argv, lane), .lane = .{ .dhat = lane } }; } if (options.offcpu) |lane_options| { const lane = try offcpu.plan(allocator, lane_options, workload_root); if (!tool_available) return .{ .argv = argv, .lane = .{ .offcpu = lane } }; return .{ .argv = try offcpu.wrapArgv(allocator, lane_options, argv, lane), .lane = .{ .offcpu = lane } }; } if (options.coverage) |lane_options| { const lane = try coverage.plan(allocator, lane_options, workload_root); if (!tool_available) return .{ .argv = argv, .lane = .{ .coverage = lane } }; return .{ .argv = try coverage.wrapArgv(allocator, lane_options, argv, lane), .lane = .{ .coverage = lane } }; } return .{ .argv = argv };}Source: src/profiling/host/root.zig
const runtime = @import("runtime.zig");pub const counters = runtime.counters;pub const coverage = runtime.coverage;pub const dhat = runtime.dhat;pub const offcpu = runtime.offcpu;pub const process = runtime.process;pub const sampling = runtime.sampling;pub const state = @import("state.zig");pub const scope = runtime.scope;pub const direct_scope = runtime.direct_scope;pub const ProbeRequest = runtime.ProbeRequest;pub const ToolProbe = runtime.ToolProbe;pub const Options = runtime.Options;pub const Capture = runtime.Capture;pub const Wrapped = runtime.Wrapped;pub const Lane = runtime.Lane;pub const wrap = runtime.wrap;pub const resetCaptureArtifacts = runtime.resetCaptureArtifacts;pub const summarize = runtime.summarize;pub const missingBinary = runtime.missingBinary;pub const setupFailed = runtime.setupFailed;pub const warmupFailed = runtime.warmupFailed;pub const probe = runtime.probe;Source: src/profiling/root.zig:26
pub const host = @import("host/root.zig");Complete call list for host.wrap
9 direct calls.
tiny.profiling.host.counters.plan[function] atsrc/profiling/host/counters.zig:47tiny.profiling.host.counters.wrapArgv[function] atsrc/profiling/host/counters.zig:211tiny.profiling.host.coverage.wrapArgv[function] atsrc/profiling/host/coverage.zig:40tiny.profiling.host.dhat.plan[function] atsrc/profiling/host/dhat.zig:20tiny.profiling.host.dhat.wrapArgv[function] atsrc/profiling/host/dhat.zig:29tiny.profiling.host.offcpu.plan[function] atsrc/profiling/host/offcpu.zig:42tiny.profiling.host.offcpu.wrapArgv[function] atsrc/profiling/host/offcpu.zig:59tiny.profiling.host.sampling.plan[function] atsrc/profiling/host/sampling.zig:63tiny.profiling.host.sampling.wrapArgv[function] atsrc/profiling/host/sampling.zig:104
Audit
| Definitions | 23 |
|---|---|
| Public names | 23 |
| Members | 25 |
| Version | 26.7.0 |
| Revision | daab053ee433 |