Expand description
§coren: compute and resource normalization
Two layers:
- FnCost – deterministic descriptor of what a function requires. Absolute physical units (ops, bytes). Same on every machine.
- MachCap – what this machine can do. Measured locally.
One answer:
let v = cap.verdict(&cost);
if v.score > 0.0 { fetch from network }
if v.score < 0.0 { compute locally }
// magnitude = seconds saved by choosing the better option§FnCost fields (all deterministic, all u64)
| Field | Meaning |
|---|---|
| ops | Total arithmetic operations |
| mem_bytes | Memory traffic (cold-cache model) |
| peak_mem | Peak footprint (max simultaneously live) |
| result_bytes | Output size (what gets cached/sent) |
These use integer arithmetic throughout. No floats in constructors. Two machines cannot disagree on a FnCost.
§Example
use coren::{FnCost, MachCap};
let cost = FnCost::sort(1_000_000, 64, 64_000_000);
let cap = MachCap::read(".");
let v = cap.verdict(&cost);
if v.score > 0.0 {
println!("fetch: saves {:.2}s", v.score);
} else {
println!("compute: saves {:.2}s", -v.score);
}Structs§
- FnCost
- Deterministic descriptor of a function’s resource requirements.
- MachCap
- Local machine capabilities. Translates deterministic FnCost into a Verdict: compute or fetch?
- Roofline
- Verdict
- The answer: should this machine compute or fetch?