pub struct CacheCostParams {
pub c_miss_us: f64,
pub c_mem_per_byte: f64,
pub item_bytes: f64,
pub working_set_n: f64,
pub zipf_alpha: f64,
pub budget_max_bytes: f64,
}Expand description
Parameters for the glyph/cell cache cost model.
Fields§
§c_miss_us: f64Cost of a cache miss in µs (rasterize + upload).
c_mem_per_byte: f64Opportunity cost per byte of atlas memory (µs/byte/frame).
item_bytes: f64Average item size in bytes (slot area including padding).
working_set_n: f64Working set size (number of distinct glyphs in a typical session).
zipf_alpha: f64Zipf exponent for access frequency distribution. α > 1 means heavy-tail (few glyphs dominate); typical terminal ≈ 1.2–1.8.
budget_max_bytes: f64Maximum allowed cache budget in bytes.
Implementations§
Source§impl CacheCostParams
impl CacheCostParams
Sourcepub fn miss_rate(&self, budget_bytes: f64) -> f64
pub fn miss_rate(&self, budget_bytes: f64) -> f64
Compute the miss rate under LRU with IRM/Zipf workload.
Approximation: miss_rate(B) ≈ 1 − min(1, (capacity / N))^(1/α)
where capacity = B / item_bytes.
Sourcepub fn total_cost(&self, budget_bytes: f64) -> f64
pub fn total_cost(&self, budget_bytes: f64) -> f64
Total cost J(B) = c_miss × miss_rate(B) × N_accesses + c_mem × B.
We normalize to per-frame cost assuming working_set_n accesses/frame.
Sourcepub fn evaluate(&self, budget_bytes: f64) -> CacheCostPoint
pub fn evaluate(&self, budget_bytes: f64) -> CacheCostPoint
Evaluate a single point on the cost surface.
Sourcepub fn optimal_budget(&self) -> f64
pub fn optimal_budget(&self) -> f64
Compute the optimal cache budget analytically.
From dJ/dB = 0:
B* = item_bytes × N × (c_miss / (α × c_mem_per_byte × item_bytes × N))^(α/(1+α))clamped to [item_bytes, budget_max_bytes].
Sourcepub fn optimize(&self) -> CacheCostResult
pub fn optimize(&self) -> CacheCostResult
Run the full optimization and produce evidence.
Trait Implementations§
Source§impl Clone for CacheCostParams
impl Clone for CacheCostParams
Source§fn clone(&self) -> CacheCostParams
fn clone(&self) -> CacheCostParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more