tiny.profiling.analyze.evidence
Defined in analyze.
API (8)
Actions
Public operations.
causal_result_descendingcomparisonEvidenceflattenCapturesflattenCausaloutliersByRssoutliersByWallsortedByRsssortedByWall
Source
Source: src/profiling/analyze/evidence.zig
zig
const std = @import("std");const budget = @import("../root.zig").budget;const coz = @import("../capture/root.zig").coz;const memory = @import("../root.zig").memory;const metric = @import("../root.zig").metric;const priority = @import("../root.zig").priority;const Comparison = @import("root.zig").model.Comparison;const CounterShift = @import("root.zig").model.CounterShift;const EnergyShift = @import("root.zig").model.EnergyShift;const NamedCapture = @import("root.zig").model.NamedCapture;const OrderEffects = @import("root.zig").model.OrderEffects;const Run = @import("root.zig").model.Run;const Workload = @import("root.zig").model.Workload;const WorkloadComparisonSkip = @import("root.zig").model.WorkloadComparisonSkip;const allocationBudgetChecks = @import("root.zig").compare.allocationBudgetChecks;const buildOrderEffects = @import("root.zig").ordering.buildOrderEffects;const compareCounterRuns = @import("root.zig").compare.compareCounterRuns;const compareEnergyRuns = @import("root.zig").compare.compareEnergyRuns;const compareMemoryRuns = @import("root.zig").compare.compareMemoryRuns;const compareMetricRuns = @import("root.zig").compare.compareMetricRuns;const compareRuns = @import("root.zig").compare.compareRuns;const supportedBaseline = @import("root.zig").compare.supportedBaseline;const workloadComparisonSkips = @import("root.zig").compare.workloadComparisonSkips;const ComparisonEvidence = struct { order_effects: ?OrderEffects, workload: []const Comparison, skips: []const WorkloadComparisonSkip, metrics: []const metric.Comparison, memory_metrics: []const memory.Comparison, allocation_budgets: []const budget.Check, energy: []const EnergyShift, counters: []const CounterShift, priority_report: priority.Report,};pub fn comparisonEvidence( allocator: std.mem.Allocator, candidate: Run, baseline_run: ?Run, threshold_percent: f64, causal: []const coz.Result,) !ComparisonEvidence { const order_effects = if (baseline_run) |base| try buildOrderEffects(allocator, base, candidate) else null; const comparable_base = supportedBaseline(baseline_run, candidate); const regression_base = if (order_effects == null) comparable_base else null; const workload = if (regression_base) |base| try compareRuns(allocator, base, candidate, threshold_percent) else &.{}; const skips = if (comparable_base) |base| try workloadComparisonSkips(allocator, base, candidate) else &.{}; const metrics = if (regression_base) |base| try compareMetricRuns(allocator, base, candidate, threshold_percent) else &.{}; const memory_metrics = if (regression_base) |base| try compareMemoryRuns(allocator, base, candidate, threshold_percent) else &.{}; const allocation_budgets = try allocationBudgetChecks( allocator, candidate, baseline_run, ); const energy = if (regression_base) |base| try compareEnergyRuns(allocator, base, candidate, threshold_percent) else &.{}; const counters = if (regression_base) |base| try compareCounterRuns(allocator, base, candidate, threshold_percent) else &.{}; const report = if (regression_base != null) try priority.build( allocator, try priorityWorkloads(allocator, candidate), workload, metrics, memory_metrics, causal, ) else priority.Report{}; return .{ .order_effects = order_effects, .workload = workload, .skips = skips, .metrics = metrics, .memory_metrics = memory_metrics, .allocation_budgets = allocation_budgets, .energy = energy, .counters = counters, .priority_report = report, };}pub fn flattenCaptures(allocator: std.mem.Allocator, run_value: Run) ![]const NamedCapture { var rows: std.ArrayList(NamedCapture) = .empty; for (run_value.workloads) |workload| { for (workload.captures) |row| try rows.append(allocator, .{ .workload = workload.name, .capture = row }); } return try rows.toOwnedSlice(allocator);}pub fn causal_result_descending(_: void, left: coz.Result, right: coz.Result) bool { const left_supported = left.support.status == .within_run_repeated_curve; const right_supported = right.support.status == .within_run_repeated_curve; if (left_supported != right_supported) return left_supported; if (left.max_program_speedup == right.max_program_speedup) { return std.mem.lessThan(u8, left.workload, right.workload); } return left.max_program_speedup > right.max_program_speedup;}pub fn flattenCausal(allocator: std.mem.Allocator, run_value: Run) ![]const coz.Result { var result: std.ArrayList(coz.Result) = .empty; for (run_value.workloads) |workload| { for (workload.causal) |row| try result.append(allocator, row); } const slice = try result.toOwnedSlice(allocator); std.mem.sort(coz.Result, slice, {}, causal_result_descending); return slice;}fn priorityWorkloads(allocator: std.mem.Allocator, run_value: Run) ![]const priority.WorkloadSummary { var result: std.ArrayList(priority.WorkloadSummary) = .empty; for (run_value.workloads) |workload| { try result.append(allocator, .{ .name = workload.name, .package = workload.package, .step = workload.step, .wall_ns = workload.wall_ns, .max_rss_kib = workload.max_rss_kib, }); } return try result.toOwnedSlice(allocator);}fn workload_wall_descending(items: []const Workload, left: usize, right: usize) bool { return items[left].wall_ns > items[right].wall_ns;}fn workload_rss_value(item: Workload) i64 { return item.max_rss_kib orelse -1;}fn workload_rss_descending(items: []const Workload, left: usize, right: usize) bool { return workload_rss_value(items[left]) > workload_rss_value(items[right]);}pub fn sortedByWall(allocator: std.mem.Allocator, workloads: []const Workload) ![]usize { const indices = try ordinalIndices(allocator, workloads.len); std.mem.sort(usize, indices, workloads, workload_wall_descending); return indices;}pub fn sortedByRss(allocator: std.mem.Allocator, workloads: []const Workload) ![]usize { const indices = try ordinalIndices(allocator, workloads.len); std.mem.sort(usize, indices, workloads, workload_rss_descending); return indices;}pub fn outliersByWall(allocator: std.mem.Allocator, workloads: []const Workload) ![]usize { if (workloads.len < 3) return &.{}; const median = (try medianWall(allocator, workloads)) orelse return &.{}; if (median == 0) return &.{}; var result: std.ArrayList(usize) = .empty; for (workloads, 0..) |workload, index| { if (@as(f64, @floatFromInt(workload.wall_ns)) > @as(f64, @floatFromInt(median)) * 3) try result.append(allocator, index); } return try result.toOwnedSlice(allocator);}pub fn outliersByRss(allocator: std.mem.Allocator, workloads: []const Workload) ![]usize { if (workloads.len < 3) return &.{}; const median = (try medianRss(allocator, workloads)) orelse return &.{}; if (median <= 0) return &.{}; var result: std.ArrayList(usize) = .empty; for (workloads, 0..) |workload, index| { const rss = workload.max_rss_kib orelse continue; if (@as(f64, @floatFromInt(rss)) > @as(f64, @floatFromInt(median)) * 3) try result.append(allocator, index); } return try result.toOwnedSlice(allocator);}fn medianWall(allocator: std.mem.Allocator, workloads: []const Workload) !?u64 { const values = try allocator.alloc(u64, workloads.len); for (workloads, 0..) |workload, index| values[index] = workload.wall_ns; std.mem.sort(u64, values, {}, std.sort.asc(u64)); return values[values.len / 2];}fn medianRss(allocator: std.mem.Allocator, workloads: []const Workload) !?i64 { var values: std.ArrayList(i64) = .empty; for (workloads) |workload| { if (workload.max_rss_kib) |rss| try values.append(allocator, rss); } if (values.items.len == 0) return null; std.mem.sort(i64, values.items, {}, std.sort.asc(i64)); return values.items[values.items.len / 2];}fn ordinalIndices(allocator: std.mem.Allocator, count: usize) ![]usize { const indices = try allocator.alloc(usize, count); for (indices, 0..) |*slot, index| slot.* = index; return indices;}Source: src/profiling/analyze/root.zig:3
zig
pub const evidence = @import("evidence.zig");Complete call list for analyze.evidence.comparisonEvidence
11 direct calls.
tiny.profiling.analyze.compare.allocationBudgetChecks[function] atsrc/profiling/analyze/compare.zig:241tiny.profiling.analyze.compare.compareCounterRuns[function] atsrc/profiling/analyze/compare.zig:481tiny.profiling.analyze.compare.compareEnergyRuns[function] atsrc/profiling/analyze/compare.zig:390tiny.profiling.analyze.compare.compareMemoryRuns[function] atsrc/profiling/analyze/compare.zig:235tiny.profiling.analyze.compare.compareMetricRuns[function] atsrc/profiling/analyze/compare.zig:229tiny.profiling.analyze.compare.compareRuns[function] atsrc/profiling/analyze/compare.zig:57tiny.profiling.analyze.compare.supportedBaseline[function] atsrc/profiling/analyze/compare.zig:41tiny.profiling.analyze.compare.workloadComparisonSkips[function] atsrc/profiling/analyze/compare.zig:173src.profiling.analyze.evidence.priorityWorkloads[function] — private; no exact target atsrc/profiling/analyze/evidence.zig:131in nearest public ownertiny.profiling.analyze.evidencetiny.profiling.analyze.ordering.buildOrderEffects[function] atsrc/profiling/analyze/ordering.zig:19tiny.profiling.priority.build[function] atsrc/profiling/priority.zig:123
Audit
| Definitions | 9 |
|---|---|
| Public names | 9 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |