perf(ibd): drop never-written confirm/query/store meters - #405
Conversation
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.
6c684c1 to
98bba3d
Compare
There was a problem hiding this comment.
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. Onmasternone has a productionfetch_add/storeoutside#[cfg(test)], except the S-02 (LOOKUP_*/ROLLS/SEALSinsegmented_head.rs) and Q-01 (PSTORE_*) groups, which are written but had no consumer (sample_head_lookup_stats/snapshot_head_lookup_statshad 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_gcinwrite=,creates=,phases hdr=/dec=/put=/new=,pstore, heaprecent=) 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/nsinventory shrinks only by the two always-zero terms. - Remaining
confirm_load_stats/confirm_phase_stats/archive_phase_statsstatics 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 anote_*fn).wf_body_store/sh_collect_pinfrom 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 onmasterfor the unconditional tokens (tip_gc=,recent_pub=,parent_io=,cold_idx=,pread=,creates=,pstore,recent=, dbgedges same=) and drives shippedformat_info/format_debug/format_sizes. Several of the other assertions (recon_ms,wire_ms,resolve_ms,miss_p,spend_mix) wereappend_nz/conditional onmasterand so were already green with a zero sample — harmless, just not load-bearing. - Deleting
lookup_stats_sample_and_snapshot_surfaceis right; it asserted nothing (let _ = any;). - CHANGELOG / OPERATOR.md /
docs/ibd-memory.mdupdated for the DEBUG token shrink as the inventory asks. - Second force-push (
6c684c14→98bba3d7) 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:352let tip_gc_ns = 0u64;returned frompost_commitas the second tuple element,- threaded through
write.rs:240/258/294intoLastWritePhases.tip_gc_ns, - stored in
LAST_WRITE_TIP_GC_NS(consensus/lib.rs:210/253/269), - and printed as
tip_gc={}msin theibd: 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::noteare test-only scaffolding (the only writer of that struct isquery_tests::sampler_stats; every static it feeds already has a real writer inconfirm_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 thepub use; havesampler_statsassert the sampler viasample_and_resetafter driving the real accrual (or drop that block). Thenconfirm_load.rsis twoQuerypassthroughs and can fold intoconfirm_parent_cache.rsas 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_resetnow 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.
| 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=`, |
There was a problem hiding this comment.
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 { | |||
There was a problem hiding this comment.
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.
Summary
X-01 step (1) from the complexity inventory: delete never-incremented confirm/query/store perf meters so
ibd: perf/ibd: sizescannot 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, annotatepread=,spend_mix i=/skip=,pstore, or always-zero heaprecent=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-zerotip_gc/recent_pub. Last-pin / last-write snapshots stay.Also deletes unused
HeadLookupStatssample/snapshot (never consumed byibd: perf) and the matching store fetch_adds.Not in this PR: instance-owned stats handle, test mutex /
cfg(not(test))twins, table-drivenperf_log(X-01 steps 2–3).Test plan
format_lines_omit_never_written_inventory_tokensdrives shippedformat_info/format_debug/format_sizes.cargo test -p rbitcoin-net --lib ibd::perf_log, plus querysampler_stats/size_snapshot_counts, consensuslast_write_phase_stats, storesegmented_head.