Attribute herder/overlay heap in the periodic memory report - #3938
Attribute herder/overlay heap in the periodic memory report#3938tomerweller wants to merge 1 commit into
Conversation
Add a Weak-reporter registry to LedgerManager so the every-64-ledger memory report folds in per-subsystem heap components from the herder (tx queue, SCP-slot retention, fetching envelopes, quorum + externalize -lag maps) and overlay (flood gate, peer maps, known/banned peer sets), shrinking the 97.5% unaccounted region the 42h soak documented. - henyey-common: object-safe MemoryReporter trait + btreemap/vecdeque heap helpers. - ledger: memory_reporters registry + register_memory_reporter (&self, Weak) + extracted collect_and_prune_reporters helper folded into build_memory_report after ledger-owned components (locks released first — no deadlock against reporter callbacks). - herder/overlay: O(1) estimate_heap_bytes on the owned collections and MemoryReporter impls; app wires both registrations so the impls have a production call path. Observability-only: read-only heap estimates and additive log fields; no observable-surface change. Refs #3845 Co-authored-by: Claude Code <claude-code@anthropic.com>
🔍 Reviewer: CorrectnessVerdict: APPROVE Summary: Observability-only Weak-reporter registry with thorough unit coverage for every new public surface; no correctness concerns. Full reviewCycle 1 (no prior Issue kind: enhancement/feature. Test-verification gate (feature ⇒ every new
Correctness:
No blocking concerns. Non-blocking notes (not gating): the |
🔍 Reviewer: ParityVerdict: APPROVE Summary: Purely internal observability — read-only heap estimates plus additive log fields in the periodic memory report; no observable/interop-surface change. Full reviewCycle 1 (no prior The diff touches parity crates ( This change touches none of them:
No observable-surface concern. Nothing to flag under the parity lens. |
Closes #3845
Summary
Adds a
Weak-reporter registry toLedgerManagerso the existing every-64-ledger memory report folds in per-subsystem heap components from the herder (tx queue, SCP-slot retention, fetching envelopes, quorum + externalize-lag maps) and overlay (flood gate, peer maps, known/banned peer sets). This directly targets the 97.5% unaccounted region the 42h soak in #3845 documented — the named components previously tracked only ~2.5% of a 10 GB anon swing.The aggregation point stays where it is (the ledger-close
build_memory_report), so new components are co-sampled with RSS/jemalloc exactly like today's; only what that call can see is widened.MemoryReporterlives inhenyey-common, so the ledger holdsWeak<dyn MemoryReporter>without naming concrete subsystem types and without a crate-dependency inversion.Weakis mandatory: the herder/overlay holdArc<LedgerManager>, so a strong back-ref would form a leak-cycle. Dead reporters upgrade toNoneand are pruned.Each
memory_components()calls O(1)/O(bounded)estimate_heap_bytes()methods that read capacities/lengths only, take short-lived locks, and never re-enter the ledger — so the report path cannot deadlock. The weak-upgrade/merge/prune step is an extracted free helper (collect_and_prune_reporters) that releases the registry lock before invoking any reporter callback.Plan reference
Converged Plan comment
Test plan
cargo fmt --checkcargo clippy -p henyey-common -p henyey-ledger -p henyey-herder -p henyey-overlay -p henyey-app --all-targets -- -D warningscargo test -p henyey-common -p henyey-ledger -p henyey-herder -p henyey-overlay— all greenNew coverage (per the plan's "New coverage" list):
henyey-common:test_btreemap_heap_bytes_*,test_vecdeque_heap_bytes.test_register_memory_reporter_appends_components,test_dropped_memory_reporter_is_skipped(via the extracted helper), plustest_register_memory_reporter_via_manager.estimate_heap_bytestest per subsystem (tx_queue, fetching_envelopes, quorum_tracker, externalize_lag) +test_herder_memory_components_names.test_overlay_memory_components_names.Parity considerations
n/a — no observable-surface change. Adds read-only heap estimates and additive
heap_components_mb/"Memory report component"log fields only;estimate_heap_bytes()is pure. The reservedmemory_report=truefield is preserved (thetest_memory_report_emits_field_*suite still passes).Deviations from plan
🤖 Generated with Claude Code