MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / to_byte_budgets

Method to_byte_budgets

nodedb/src/config/engine.rs:140–147  ·  view source on GitHub ↗

Convert fractions to absolute byte budgets for every `EngineId`, given the global memory limit.

(&self, global_limit: usize)

Source from the content-addressed store, hash-verified

138 /// Convert fractions to absolute byte budgets for every `EngineId`,
139 /// given the global memory limit.
140 pub fn to_byte_budgets(&self, global_limit: usize) -> EngineByteBudgets {
141 let gl = global_limit as f64;
142 let per_engine = EngineId::ALL
143 .iter()
144 .map(|&e| (e, (gl * self.fraction_for(e)) as usize))
145 .collect();
146 EngineByteBudgets { per_engine }
147 }
148}
149
150/// Absolute byte budgets for every `EngineId`, derived from fractional config.

Callers 6

mainFunction · 0.80
init_from_default_configFunction · 0.80
fresh_boot_governorFunction · 0.80

Calls 3

collectMethod · 0.80
fraction_forMethod · 0.80
iterMethod · 0.45

Tested by 3

init_from_default_configFunction · 0.64