Skip to documentation
SLOP

tiny.profiling.driver.run

Reference tiny.profiling driver run

Defined in driver.

API (2)

Actions

Public operations.

No direct callersNo direct callsdriverrun
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callersprivate; no linksrc.profiling.driver.runfinishRunprivate; no linksrc.profiling.driver.runrunSelectedWorkloadsdriver.validationeffectiveBenchControldriver.validationeffectiveOptimizedriver.validationvalidateRequest+4 moredriver.runexecuteRun
Static calls · unresolved targets: 0 · external targets: 7.
Called byCallsprivate; no linksrc.profiling.driver.runexecuteWorkloadScratchtest; no linksrc.profiling.driver.testtest: profiling driver excludes a lat...test; no linksrc.profiling.driver.testtest: profiling driver records prepar...test; no linksrc.profiling.driver.testtest: profiling driver resets before ...test; no linksrc.profiling.driver.testtest: profiling driver resets success...+2 moredriver.acquireaggregateUnmeasuredFailuredriver.artifactvalidateRetainedTracyArtifactsdriver.measurerunMeasuredWorkloaddriver.prepareinitializeWorkloaddriver.runrunPreparedWorkload
Static calls · unresolved targets: 1 · external targets: 1.

Source: src/profiling/driver/root.zig:11

zig
pub const run = @import("run.zig");

Source: src/profiling/driver/run.zig

zig
const std = @import("std");const pretty_usage = @import("pretty_usage");const sys = @import("sys");const catalog = @import("../root.zig").catalog;const coverage = @import("../report/root.zig").coverage;const execute = @import("../root.zig").execute;const host = @import("../root.zig").host;const plan = @import("../root.zig").plan;const perturbation = @import("../root.zig").perturbation;const record = @import("../root.zig").record;const CompletedWorkload = @import("root.zig").model.CompletedWorkload;const Memory = @import("root.zig").model.Memory;const Outcome = @import("root.zig").model.Outcome;const PreparedWorkload = @import("root.zig").model.PreparedWorkload;const Request = @import("root.zig").model.Request;const RunProgress = @import("root.zig").model.RunProgress;const WorkloadContext = @import("root.zig").model.WorkloadContext;const aggregateUnmeasuredFailure = @import("root.zig").acquire.aggregateUnmeasuredFailure;const effectiveBenchControl = @import("root.zig").validation.effectiveBenchControl;const effectiveOptimize = @import("root.zig").validation.effectiveOptimize;const failureExitCode = @import("root.zig").validation.failureExitCode;const initializeWorkload = @import("root.zig").prepare.initializeWorkload;const prepareWorkload = @import("root.zig").prepare.prepareWorkload;const recordCompletedWorkload = @import("root.zig").publish.recordCompletedWorkload;const runInterleavedWorkloads = @import("root.zig").schedule.runInterleavedWorkloads;const runMeasuredWorkload = @import("root.zig").measure.runMeasuredWorkload;const runWarmups = @import("root.zig").prepare.runWarmups;const validateRequest = @import("root.zig").validation.validateRequest;const validateRetainedTracyArtifacts = @import("root.zig").artifact.validateRetainedTracyArtifacts;pub fn executeRun(    memory: Memory,    process_io: std.Io,    environ_map: ?*const sys.process.Environ.Map,    request: Request,) !Outcome {    const allocator = memory.command;    try validateRequest(request);    var effective_request = request;    effective_request.control = try effectiveBenchControl(        request.control,        request.host_lanes,    );    const optimize = effectiveOptimize(request.host_lanes);    const paths = try record.makePaths(allocator, request.output_dir, request.run_id);    const metadata = try record.collectMetadata(        allocator,        process_io,        paths,        request.selection,        optimize,    );    std.debug.assert(paths.root.len > 0);    std.debug.assert(metadata.workload_count == request.selection.count());    try record.init(allocator, paths, metadata);    const run_started_ns = sys.time.realNanoTimestamp();    try pretty_usage.Terminal.stderr(allocator, .{}).writeTextFmt(        "profile: artifacts {s}\n",        .{paths.root},    );    const probe_request = try request.host_lanes.probeRequest(allocator);    const tool_probe = if (probe_request) |probe_value|        try host.probe(allocator, process_io, probe_value)    else        host.ToolProbe{ .available = true };    if (request.host_lanes.any() and !tool_probe.available) {        try pretty_usage.Terminal.stderr(allocator, .{}).writeTextFmt(            "profile: {s} is not runnable; workloads run unwrapped with tool_missing caveats\n",            .{request.host_lanes.tool().?},        );    }    const zig_command = execute.zig(environ_map);    const context = WorkloadContext{        .backing_allocator = memory.workload,        .process_io = process_io,        .environ_map = environ_map,        .request = effective_request,        .paths = paths,        .metadata = metadata,        .zig_command = zig_command,        .tool_probe = tool_probe,        .progress_output = .terminal,    };    const progress = try runSelectedWorkloads(&context);    const run_finished_ns = sys.time.realNanoTimestamp();    return try finishRun(        allocator,        &context,        progress,        run_started_ns,        run_finished_ns,    );}fn finishRun(    allocator: std.mem.Allocator,    context: *const WorkloadContext,    progress: RunProgress,    run_started_ns: i128,    run_finished_ns: i128,) !Outcome {    std.debug.assert(progress.failures <= progress.ran);    std.debug.assert(run_finished_ns >= run_started_ns);    std.debug.assert(progress.ran <= context.request.selection.count());    std.debug.assert(context.metadata.workload_count == context.request.selection.count());    const request = context.request;    const paths = context.paths;    const metadata = context.metadata;    const failures = progress.failures;    const ran = progress.ran;    const stopped_early = progress.stopped_early;    const first_failure_exit_code = progress.first_failure_exit_code;    const exit_code: u8 = if (failures == 0)        0    else if (first_failure_exit_code == 0)        1    else        first_failure_exit_code;    try record.finish(allocator, paths, metadata, .{        .selected = request.selection.count(),        .ran = ran,        .passed = ran - failures,        .failed = failures,        .stopped_early = stopped_early,        .exit_code = exit_code,        .started_unix_ns = run_started_ns,        .finished_unix_ns = run_finished_ns,        .wall_ns = @intCast(@max(run_finished_ns - run_started_ns, 0)),    });    if (request.host_lanes.coverage != null) {        const coverage_summary = try coverage.writeRunArtifacts(            allocator,            context.process_io,            paths,            request.selection,        );        try pretty_usage.Terminal.stderr(allocator, .{}).writeTextFmt(            "profile: coverage {d}/{d} code lines ({d} workload artifact(s)), summary {s}\n",            .{                coverage_summary.covered_code_lines,                coverage_summary.code_lines,                coverage_summary.captured_workloads,                coverage_summary.summary_path,            },        );    }    return .{        .paths = paths,        .selected = request.selection.count(),        .ran = ran,        .failed = failures,        .stopped_early = stopped_early,        .exit_code = exit_code,    };}fn runSelectedWorkloads(context: *const WorkloadContext) !RunProgress {    if (context.request.interleave_seed) |seed| {        return try runInterleavedWorkloads(context, seed);    }    const selected = context.request.selection.count();    std.debug.assert(selected <= catalog.workloads.len);    var progress = RunProgress{        .ran = 0,        .failures = 0,        .first_failure_exit_code = 0,        .stopped_early = false,    };    for (catalog.workloads) |workload| {        if (!context.request.selection.selected(workload)) continue;        progress.ran += 1;        const execution_exit_code = try executeWorkload(            context,            workload,            progress.ran - 1,        );        if (execution_exit_code != 0) {            progress.failures += 1;            if (progress.first_failure_exit_code == 0) {                progress.first_failure_exit_code = failureExitCode(execution_exit_code);            }            if (!context.request.continue_on_failure) {                progress.stopped_early = true;                break;            }        }    }    std.debug.assert(progress.ran <= selected);    std.debug.assert(progress.failures <= progress.ran);    return progress;}fn executeWorkload(    context: *const WorkloadContext,    workload: catalog.Workload,    index: usize,) !i64 {    std.debug.assert(context.request.selection.selected(workload));    std.debug.assert(index < context.request.selection.count());    var arena = std.heap.ArenaAllocator.init(context.backing_allocator);    defer arena.deinit();    return try executeWorkloadScratch(arena.allocator(), context, workload, index);}fn executeWorkloadScratch(    allocator: std.mem.Allocator,    context: *const WorkloadContext,    workload: catalog.Workload,    index: usize,) !i64 {    std.debug.assert(context.request.selection.selected(workload));    std.debug.assert(index < context.request.selection.count());    const prepared = try prepareWorkload(allocator, context, workload);    try pretty_usage.Terminal.stderr(allocator, .{}).writeTextFmt(        "profile: {s}\n",        .{prepared.command},    );    const started_unix_ns = sys.time.realNanoTimestamp();    const completed = try runPreparedWorkload(allocator, context, workload, prepared);    const finished_unix_ns = sys.time.realNanoTimestamp();    const predecessors = try plan.precedingNames(        allocator,        context.request.selection,        workload,    );    std.debug.assert(predecessors.len == index);    return try recordCompletedWorkload(        allocator,        context,        workload,        index,        prepared,        completed,        .{ .blocked = .{            .position = index + 1,            .workload_count = context.metadata.workload_count,            .predecessors = predecessors,        } },        started_unix_ns,        finished_unix_ns,    );}pub fn runPreparedWorkload(    allocator: std.mem.Allocator,    context: *const WorkloadContext,    workload: catalog.Workload,    prepared: PreparedWorkload,) !CompletedWorkload {    std.debug.assert(prepared.paths.root.len > 0);    std.debug.assert(prepared.wrapped.argv.len > 0);    const initialization = try initializeWorkload(allocator, context, prepared);    const setup = initialization.setup;    const prepare = initialization.prepare;    const setup_failed = initialization.setup_failed;    const prepare_failed = initialization.prepare_failed;    var warmup_failed = false;    var reset_failed = false;    var execution: execute.Result = undefined;    var executions: []record.MeasuredExecution = &.{};    var host_state_windows: []const host.state.Window = &.{};    var warmup_executions: []const execute.Result = &.{};    var perturbation_measurement: ?perturbation.Measurement = null;    var resets: std.ArrayList(record.Reset) = .empty;    if (initialization.failure) |failure| execution = failure;    if (initialization.failure == null) {        const warmup = try runWarmups(            allocator,            context,            workload,            prepared,            &resets,        );        warmup_executions = warmup.executions;        if (warmup.failure) |failure| {            warmup_failed = !warmup.reset_failed;            reset_failed = warmup.reset_failed;            execution = if (warmup.reset_failed)                aggregateUnmeasuredFailure(null, failure)            else                failure;        } else {            const measured = try runMeasuredWorkload(                allocator,                context,                workload,                prepared,                &resets,            );            execution = measured.aggregate;            executions = measured.executions;            host_state_windows = measured.host_state_windows;            reset_failed = measured.reset_failed;            perturbation_measurement = measured.perturbation;            if (context.request.tracy and execution.exit_code == 0) {                validateRetainedTracyArtifacts(                    prepared.paths,                    executions,                ) catch {                    execution.exit_code = 1;                };            }        }    }    return .{        .setup = setup,        .prepare = prepare,        .setup_failed = setup_failed,        .prepare_failed = prepare_failed,        .warmup_failed = warmup_failed,        .reset_failed = reset_failed,        .execution = execution,        .executions = executions,        .host_state_windows = host_state_windows,        .warmup_executions = warmup_executions,        .resets = try resets.toOwnedSlice(allocator),        .perturbation = perturbation_measurement,    };}

Complete call list for driver.run.executeRun

9 direct calls.

Complete caller list for driver.run.runPreparedWorkload

7 direct callers.

Audit

Definitions3
Public names4
Members0
Version26.7.0
Revisiondaab053ee433