Skip to content

perf(ibd): drop never-written confirm/query/store meters - #405

Merged
reardencode merged 3 commits into
masterfrom
ibd/dead-perf-meters
Sep 9, 2026
Merged

perf(ibd): drop never-written confirm/query/store meters#405
reardencode merged 3 commits into
masterfrom
ibd/dead-perf-meters

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

X-01 step (1) from the complexity inventory: delete never-incremented confirm/query/store perf meters so ibd: perf / ibd: sizes cannot name a counter that is always zero.

Shipped DEBUG no longer prints recon/wire/resolve, parent_io, miss_p, cold_idx, tip_gc, recent_pub, annotate pread=, spend_mix i=/skip=, pstore, or always-zero heap recent= occupancy. Live lookup / load / scripts / write stage tokens stay (load=, script=, write=, pin/assemble/class_a/spend/tweaks/pins/head_sub/drain_join/dequeue). write= no longer includes always-zero tip_gc/recent_pub. Last-pin / last-write snapshots stay.

Also deletes unused HeadLookupStats sample/snapshot (never consumed by ibd: perf) and the matching store fetch_adds.

Not in this PR: instance-owned stats handle, test mutex / cfg(not(test)) twins, table-driven perf_log (X-01 steps 2–3).

Test plan

  • Red then green: format_lines_omit_never_written_inventory_tokens drives shipped format_info / format_debug / format_sizes.
  • Targeted cargo test -p rbitcoin-net --lib ibd::perf_log, plus query sampler_stats / size_snapshot_counts, consensus last_write_phase_stats, store segmented_head.

rbitcoin-grok[bot] added 2 commits September 9, 2026 13:10
X-01 dead-meter cut: shipped ibd: perf / sizes still emit recon/wire/
resolve, parent_io, miss_p, cold_idx, recent_pub, tip_gc, pstore, and
always-zero recent occupancy even though those counters are never
incremented. Fail until sample/format drop them. Live load/script/write
stage tokens must stay.
Delete statics, Sample fields, and format tokens with no production
fetch_add: confirm_load CREATES/edges/cold_idx/decode, reconstruct/
resolve/unpin/cache_tip/recent_pub, HeadLookupStats, and always-zero
pstore/recent occupancy. Keep live lookup/load/scripts/write stage
timers and last-pin / last-write snapshots. write= no longer includes
always-zero tip_gc/recent_pub.
@rearden-grok
rearden-grok Bot force-pushed the ibd/dead-perf-meters branch from 6c684c1 to 98bba3d Compare September 9, 2026 20:20

@rearden-grok rearden-grok Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: X-01 step 1 against complexity-inventory-2026-09-07.md

Verdict: approve once required checks are green, with one should-fix (tip_gc half-delete) that I would fold into this PR rather than a follow-up. The App token is the PR author so this is posted as COMMENT.

What I verified

  • Every deleted static is dead. 40 static … Atomic* definitions removed. On master none has a production fetch_add/store outside #[cfg(test)], except the S-02 (LOOKUP_*/ROLLS/SEALS in segmented_head.rs) and Q-01 (PSTORE_*) groups, which are written but had no consumer (sample_head_lookup_stats/snapshot_head_lookup_stats had zero call sites outside the store crate; note(...,0,0,0) was the only pstore writer). Matches the inventory's X-01 / I-05 / C-01 / Q-01 / Q-02 / S-02 lists exactly.
  • No live token dropped. Every removed format token (recon_ms/us, wire_*, resolve_*, parent_io, miss_p, cold_idx, cold_dec, edges same=, spend_mix i=/skip=, pread=, recent_pub, tip_gc in write=, creates=, phases hdr=/dec=/put=/new=, pstore, heap recent=) maps to a deleted counter or a hard-coded zero. load=/script=/write= and the pin/assemble/class_a/spend/tweaks/pins/head_sub/drain_join/dequeue inventory are intact; WriteStageSample::stage_ms/ns inventory shrinks only by the two always-zero terms.
  • Remaining confirm_load_stats / confirm_phase_stats / archive_phase_stats statics are all live — spot-checked ~60 of them; each has a production writer (pin.rs, lookup.rs, phases.rs, block/mod.rs, connect.rs, reconstruct.rs, or a note_* fn). wf_body_store / sh_collect_pin from I-05 are live (reconstruct.rs:14, connect.rs:647) so keeping them is correct.
  • Red → Green is real. format_lines_omit_never_written_inventory_tokens (7398bd5) fails on master for the unconditional tokens (tip_gc=, recent_pub=, parent_io=, cold_idx=, pread=, creates=, pstore, recent=, dbg edges same=) and drives shipped format_info / format_debug / format_sizes. Several of the other assertions (recon_ms, wire_ms, resolve_ms, miss_p, spend_mix) were append_nz/conditional on master and so were already green with a zero sample — harmless, just not load-bearing.
  • Deleting lookup_stats_sample_and_snapshot_surface is right; it asserted nothing (let _ = any;).
  • CHANGELOG / OPERATOR.md / docs/ibd-memory.md updated for the DEBUG token shrink as the inventory asks.
  • Second force-push (6c684c1498bba3d7) is a same-tree, same-message amend (CI retrigger) — fine per AGENTS.

Should fix (in this PR)

tip_gc is half-deleted. The write= token is gone, but the always-zero meter survives end-to-end:

  • confirm_run/phases.rs:352 let tip_gc_ns = 0u64; returned from post_commit as the second tuple element,
  • threaded through write.rs:240/258/294 into LastWritePhases.tip_gc_ns,
  • stored in LAST_WRITE_TIP_GC_NS (consensus/lib.rs:210/253/269),
  • and printed as tip_gc={}ms in the ibd: confirm write slow … INFO line (ibd/confirm/mod.rs:1465-1475).

The PR's stated contract is that no log line names a counter that is always zero, and the CHANGELOG entry says tip_gc is dropped — the INFO line still prints it. Delete the plumbing: post_commit returns just spend_ann_ns, drop the LastWritePhases field / static / snapshot field, and the tip_gc= token from the slow-batch line. note_last_write is called from write.rs:283 and the coverage test, so the fix is small and the existing last_write_phase_stats test pins it.

Non-blocking

  • Q-03 trimmed instead of deleted. ConfirmLoadStats + #[cfg(test)] confirm_load_stats::note are test-only scaffolding (the only writer of that struct is query_tests::sampler_stats; every static it feeds already has a real writer in confirm_run/pin.rs). The PR removes 12 of its fields, which is wasted motion on a struct the same inventory step says to delete. Suggest: delete the struct, note, and the pub use; have sampler_stats assert the sampler via sample_and_reset after driving the real accrual (or drop that block). Then confirm_load.rs is two Query passthroughs and can fold into confirm_parent_cache.rs as Q-03 says. Fine as a follow-up if you want this PR to stay pure deletion.
  • Inventory suggested order was X-04 (visibility pass) before this step so rustc lists the truly dead items. Skipping it means completeness here rests on grep; I did not find any additional never-written meter in the modules touched, but the X-04 pass will be the real check.
  • sample_assemble_prevout_detail_and_reset now returns a 4-tuple of counts; the doc comment is updated, name is fine.

No behavior change outside DEBUG/INFO log text; no SCHEMA impact.

Comment thread CHANGELOG.md
Published GitHub Releases remain 0.6.0; `v0.6.x` is the patch branch.
- **`ibd: perf` / `ibd: sizes` drop never-written meters:** DEBUG no longer
prints `recon`/`wire`/`resolve`, `parent_io`, `miss_p`, `cold_idx`,
`tip_gc`, `recent_pub`, annotate `pread=`, `spend_mix i=/skip=`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tip_gc is only dropped from ibd: perf write=. It is still printed as tip_gc={}ms in the ibd: confirm write slow … INFO line (crates/rbitcoin-net/src/ibd/confirm/mod.rs:1465-1475), fed by post_commit's hard-coded let tip_gc_ns = 0u64; (confirm_run/phases.rs:352) through LastWritePhases.tip_gc_ns / LAST_WRITE_TIP_GC_NS. Delete that plumbing in this PR so the entry is true.

@@ -14,7 +14,6 @@ pub type SpendEdges = U64Map<Vec<crate::SpendEdge>>;
pub struct ConfirmLoadStats {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q-03 in the inventory: this struct and confirm_load_stats::note are #[cfg(test)]-only scaffolding — the only writer is query_tests::sampler_stats, and every static note feeds is already accrued in production by confirm_run/pin.rs. Trimming 12 fields off a dead struct is wasted motion; delete the struct + note + pub use (and fold the two remaining Query passthroughs into confirm_parent_cache.rs). OK as a follow-up if you want this PR to stay pure meter deletion.

Write no longer GCs header plans (load-owned). post_commit returned a
hard-coded 0 ns that still printed on ibd: confirm write slow. Remove
the LastWritePhases field and the INFO token.
@reardencode
reardencode merged commit 6b9b4dc into master Sep 9, 2026
16 checks passed
@rearden-grok
rearden-grok Bot deleted the ibd/dead-perf-meters branch September 9, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant