Crate grafos_profile

Crate grafos_profile 

Source
Expand description

Program-level resource profiler for grafOS.

Answers “where are my leases going?” — the grafOS equivalent of a CPU flame graph, but for resource consumption. Produces resource flame graphs, lease timelines, data-flow diagrams, and waste reports from grafos_observe::ResourceSpan data.

§Quick start

use grafos_profile::{ProfileRecording, ProfileSummary, WasteReport};
use grafos_profile::span_json::SpanJson;
use grafos_observe::span::ResourceSpan;
use grafos_observe::trace::TraceContext;
use grafos_observe::event::ResourceType;

// Build a recording from in-memory spans
let random: [u8; 24] = [0x42; 24];
let ctx = TraceContext::new_root(&random);
let mut span = ResourceSpan::new("my_op", ctx);
span.start_time_unix_us = 1_000_000;
span.end_time_unix_us = 2_000_000;
span.lease_cost_byte_secs = 4096;
span.bytes_read = 1024;
span.record_op(ResourceType::Mem, grafos_observe::event::OpType::Read, 10);
span.add_lease_id(1);

let recording = ProfileRecording::from_spans(vec![span]);
let summary = ProfileSummary::from_recording(&recording);
assert_eq!(summary.span_count, 1);

let waste = WasteReport::from_recording(&recording);
assert!(waste.total_waste_byte_secs == 0 || waste.total_waste_byte_secs > 0);

§Feature flags

FeatureDefaultEffect
stdYesEnables file I/O, serde_json for recording persistence
htmlYesEnables HTML report generation (flame graph, timeline, etc.)

Modules§

span_json
JSON serialization for ResourceSpan.

Structs§

DataFlowDiagram
Data-flow diagram inferred from a recording.
DataFlowEdge
A directed edge in the data-flow diagram.
DataFlowNode
A node in the data-flow diagram.
DimensionScore
Sensitivity score for a single resource dimension.
FlameFrame
A single frame in the flame graph.
FlameGraph
Resource flame graph computed from a span tree.
LeaseTimeline
Lease timeline (Gantt chart) computed from a recording.
LeaseTimelineEntry
A single lease’s lifecycle entry for the timeline.
ProfileRecorder
Records ResourceSpan data from a running program.
ProfileRecording
An ordered sequence of ResourceSpan records from a program run.
ProfileSummary
Aggregated profile statistics.
ResourceTypeSummary
Per-resource-type aggregated statistics.
SpanTree
Hierarchical reconstruction of spans from parent-child relationships.
SpanTreeNode
A node in the hierarchical span tree.
WasteEntry
A single lease’s waste analysis.
WasteReport
Waste report computed from a recording.
WorkloadProfile
Workload sensitivity profile inferred from observed behavior.

Enums§

DataFlowNodeKind
Kind of node in the data-flow graph.
SensitivityLevel
Sensitivity level for a resource dimension.
WasteClassification
Waste classification for a lease.

Functions§

infer_sensitivity
Infer a sensitivity profile from a recording.