Skip to main content

Module validate

Module validate 

Source
Expand description

Native validation harness: the agent’s reward function.

Builds the scheduler, attaches it on the host (as root), drives a workload, extracts a single metric, always tears the scheduler down (verifying the kernel returns to disabled), and returns a Verdict. Runs in-process; the equivalent logic previously lived in a separate run_validation.py.

Stages mirror the old harness: spec / build / preflight / attach / metric / complete. A non-complete verdict means the candidate did not build, attach, or produce a measurable result this round.

StructsΒ§

Measurement πŸ”’
One scheduler+workload run.
Scheduler πŸ”’
Launch/teardown of the scheduler with hard safety guarantees.
TraceRecorder πŸ”’
TraceStats πŸ”’
Verdict

ConstantsΒ§

SCX_STATE_PATH πŸ”’

FunctionsΒ§

binary_help πŸ”’
Capture the scheduler binary’s --help text (stdout+stderr) so we can probe which optional flags it supports before launching it. Passing an unknown argument makes the scheduler exit before attaching, so flags that are not universal must be gated on this. Empty string on any failure.
binary_path πŸ”’
cargo maps release/dev to target/{release,debug}; named profiles land in target/.
cargo_build πŸ”’
cargo build the candidate. Returns (ok, combined stdout+stderr).
cpu_event_rate_summary πŸ”’
event_counts_json πŸ”’
event_rates_json πŸ”’
exec_scheduler_foreground
Replace this process with the scheduler in the current terminal.
extract_metric πŸ”’
Parse the workload command output as the single numeric metric value. Any extraction or aggregation belongs in the command itself.
fail πŸ”’
Build a non-complete verdict (build/preflight/attach/metric/spec stages).
measure_once πŸ”’
median πŸ”’
perf_available πŸ”’
perf_mmap_pages_per_cpu πŸ”’
Per-CPU mmap pages for perf record -m, derived from a total byte budget split across the online CPUs. This controls perf’s live mmap buffer; the output file is separately capped with perf record --max-size.
pstdev πŸ”’
Population standard deviation (matches Python statistics.pstdev).
rate_value πŸ”’
read_lossy πŸ”’
round_trace_float πŸ”’
rounded_option πŸ”’
run_capture πŸ”’
Run a shell command to completion or until timeout, capturing combined stdout+stderr to out_path. A fixed-duration workload is expected to be cut off at the timeout; its partial output is still returned.
run_validation
Build the candidate, attach it, drive the workload, and return a verdict.
scx_is_enabled πŸ”’
scx_state πŸ”’
Return the sched_ext root state (β€œdisabled”/β€œenabled”/…) or None.
sleep_interruptible πŸ”’
Sleep up to duration, returning true if interrupted before the deadline.
sorted_counts πŸ”’
summarize_trace πŸ”’
tail πŸ”’
trace_cpu πŸ”’
trace_event πŸ”’
trace_stats_json πŸ”’
trace_window_sec πŸ”’
update_trace_stats πŸ”’
wait_for_state πŸ”’
Poll the sched_ext state until it equals want or the timeout elapses.