MCPcopy Create free account
hub / github.com/argumentcomputer/ix / compute_effective_sizes

Function compute_effective_sizes

crates/ixon/src/sharing.rs:392–409  ·  view source on GitHub ↗

Compute effective sizes for all subterms in topological order. Returns a map from hash to effective size (total serialized bytes).

(
  info_map: &HashMap<blake3::Hash, SubtermInfo>,
  topo_order: &[blake3::Hash],
)

Source from the content-addressed store, hash-verified

390/// Returns a map from hash to effective size (total serialized bytes).
391pub fn compute_effective_sizes(
392 info_map: &FxHashMap<blake3::Hash, SubtermInfo>,
393 topo_order: &[blake3::Hash],
394) -> FxHashMap<blake3::Hash, usize> {
395 let mut sizes: FxHashMap<blake3::Hash, usize> = FxHashMap::default();
396
397 for hash in topo_order {
398 if let Some(info) = info_map.get(hash) {
399 let mut size = info.base_size;
400 for child_hash in &info.children {
401 size += sizes.get(child_hash).copied().unwrap_or(0);
402 }
403 sizes.insert(*hash, size);
404 }
405 }
406
407 sizes
408}
409
410/// Analyze sharing statistics for debugging pathological cases.
411/// Returns a summary of why sharing may not be effective.
412#[allow(dead_code)]

Callers 4

analyze_sharing_statsFunction · 0.85
decide_sharingFunction · 0.85
test_early_break_bugFunction · 0.85

Calls 2

getMethod · 0.45
insertMethod · 0.45

Tested by 1

test_early_break_bugFunction · 0.68