| 166 | |
| 167 | |
| 168 | def summarise(p: dict, names: dict[str, str]) -> dict: |
| 169 | s = defaultdict(int) |
| 170 | for addr, r in p["sites"].items(): |
| 171 | s["slack_bytes"] += max(r["usable_bytes"] - r["requested_bytes"], 0) |
| 172 | for k in ("never_written_bytes", "over_requested_bytes", "zero_untouched_bytes", |
| 173 | "realloc_copy_bytes", "short_lived", "raw_bytes", "acc_untouched_bytes", |
| 174 | "acc_dead_bytes", "acc_idle_bytes", "acc_uninit_reads", "acc_opaque_blocks"): |
| 175 | s[k] += r.get(k, 0) |
| 176 | snap = p["snap_max"].get(addr, {}) |
| 177 | s["dup_bytes_max"] += snap.get("dup_bytes", 0) |
| 178 | s["retained_bytes_max"] += snap.get("retained_bytes", 0) |
| 179 | for (kind, addr), w in p["work"].items(): |
| 180 | if kind in CONTAINER_KINDS: |
| 181 | s["container_idle_peak_bytes"] += w.get("peak", max(w["bytes"] - w["aux1"], 0)) |
| 182 | if kind == "ct_hash_table": |
| 183 | s["ht_growths"] += w["aux2"] |
| 184 | elif kind in BYTE_KINDS: |
| 185 | if ALLOCATOR_SYMBOL.match(names.get(addr, "")): |
| 186 | s["allocator_byte_work_bytes"] += w["bytes"] |
| 187 | else: |
| 188 | s["byte_work_bytes"] += w["bytes"] |
| 189 | s["byte_work_repeats"] += w["repeats"] |
| 190 | elif kind in IO_KINDS: |
| 191 | s["io_tiny_calls"] += w["aux1"] |
| 192 | elif kind in PATH_KINDS: |
| 193 | s["path_repeats"] += w["repeats"] |
| 194 | elif kind == "mutex": |
| 195 | s["mutex_contended"] += w["aux1"] |
| 196 | elif kind == "parallel_for": |
| 197 | s["pool_imbalance_items"] += w["aux1"] |
| 198 | elif kind == "pool_ops": |
| 199 | s["pool_ops_imbalance"] += w["aux1"] |
| 200 | elif kind == "ht_get": |
| 201 | s["ht_repeat_lookups"] += w["repeats"] |
| 202 | return dict(s) |
| 203 | |
| 204 | |
| 205 | def fmt(v: float, unit: str) -> str: |