Skip to main content

Crate coren

Crate coren 

Source
Expand description

§coren: compute and resource normalization

Two layers:

  1. FnCost – deterministic descriptor of what a function requires. Absolute physical units (ops, bytes). Same on every machine.
  2. 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)

FieldMeaning
opsTotal arithmetic operations
mem_bytesMemory traffic (cold-cache model)
peak_memPeak footprint (max simultaneously live)
result_bytesOutput 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?

Enums§

Bottleneck
DeviceClass

Functions§

bench_disk_bw
bench_gflops
bench_mem_bw
detect_nic_speed
print_report