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], )
| 390 | /// Returns a map from hash to effective size (total serialized bytes). |
| 391 | pub 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)] |