Skip to content

ibd: unified peer byte-rate EWMA - #308

Merged
reardencode merged 9 commits into
masterfrom
ibd/peer-rate-ewma
Aug 30, 2026
Merged

ibd: unified peer byte-rate EWMA#308
reardencode merged 9 commits into
masterfrom
ibd/peer-rate-ewma

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • One per-peer EWMA of all streamed bytes, accrued only while that peer has block getdata in flight. Stall disconnect, relative-slow, tip-hole ranking, densify issue/steal/slots, and AddrMan FAST/SLOW all read that same bps().
  • Tip-hole cover drops one no-rx or relative-slow owner per hash instead of clearing the whole race set at 6s. Hung densify is stolen only with 30s of no qualifying rx and a faster peer with a free slot. New densify getdata is issued by EWMA rank; the height walk is skipped when every peer is at its densify cap. Default cap is 8 (2 while a tip hole is open); 16 only for a 2×-median EWMA outlier.
  • Replaces ibd: densify download by recent speed, not request age #306 (closed, not merged): same assign/densify behavior, measured with PeerRate instead of a complete-block window plus a second rx clock. Getdata issue is not rx; a uniformly slow local pipe is allowed to finish the current frame.

Test plan

  • cargo test -p rbitcoin-net --lib rate::
  • cargo test -p rbitcoin-net --lib relative_slow / disconnect_stalled / cover_tip_holes / densify_
  • Required CI: fmt, deny, clippy, ast-grep, test, windows, macos, multinode, coverage

Made with Cursor

rbitcoin-grok and others added 8 commits August 30, 2026 07:25
Integer per-peer rate accrued only while getdata is in flight. Idle
rebaseline freezes the EWMA; stall is now - max(rx, work start).

Co-authored-by: Cursor <cursoragent@cursor.com>
Stall clocks stay on the event path; the reader only fetch_adds
ciphertext/plaintext progress into bytes_rx_total for the EWMA.

Co-authored-by: Cursor <cursoragent@cursor.com>
Tip-hole peer order and AddrMan note_speed on death use the inflight
EWMA instead of lifetime complete-block speed_sample.

Co-authored-by: Cursor <cursoragent@cursor.com>
Issuing getdata only starts the 30s grace clock. Qualifying stream or
block/notfound events count as progress; hung sockets disconnect.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop the 2MiB payload floor and 60s-since-first-byte gate. Pack warmup
is still 60s since first block payload.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop one no-rx or relative-slow hole owner instead of clearing the
whole race set at 6s. Steal hung densify only when a faster peer has a
slot; issue new densify by EWMA rank; skip the band walk at cap; give
16 slots only to 2×-median outliers.

Co-authored-by: Cursor <cursoragent@cursor.com>
PeerRate is the only rate and stall clock. first_data_ms stays a plain
u64 for AddrMan latency and relative-slow pack warmup.

Co-authored-by: Cursor <cursoragent@cursor.com>
Operator stall/relative-slow text and ibd-memory densify slots now match
the single inflight EWMA; PeerRate rustdoc names the consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clippy denies dead_code on lib targets; ranking is rank_peers_by_speed
for both tip-hole cover and densify issue.

Co-authored-by: Cursor <cursoragent@cursor.com>
@reardencode
reardencode merged commit 24e46a4 into master Aug 30, 2026
13 checks passed
@rearden-grok rearden-grok Bot mentioned this pull request Aug 30, 2026
4 tasks
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