Skip to content

ibd: cadence assign, peer-slow, hygiene, headers off the event path - #317

Merged
reardencode merged 1 commit into
masterfrom
ibd/tick-cadence
Sep 3, 2026
Merged

ibd: cadence assign, peer-slow, hygiene, headers off the event path#317
reardencode merged 1 commit into
masterfrom
ibd/tick-cadence

Conversation

@rearden-grok

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

Copy link
Copy Markdown
Contributor

Why

The IBD orchestration loop still looks like a 50 ms tick, but the select! is biased to peer frames and the sleep only fires when idle. During download that means every block/header event re-ran:

  • assign_work_ordered Full — has_block over inflight, then up to FAR_SCAN_BUDGET (64 k) need_hash_at / claim_ready / body-queue lookups
  • a second assign when ≥8 inflight slots freed
  • sample_peer_rates + stall + relative-slow (stall is 30 s; relative-slow hysteresis 2 s / kick gap 5 s)
  • work-path hygiene HashMap retain (every 32 turns at event rate)
  • main-loop request_headerslocator_hashes() header-table walk

That CPU/IO is not needed for confirm to progress and competed with the pipeline. Drain + confirm-offer stay event-driven. Full 2000-header continuation still fires from the Headers event.

Cadence (good enough, less responsive)

Work Period Bypass
getdata assign 50 ms inflight empty (do not wait to start download)
header locator poll 500 ms empty work path
stall / relative-slow / cooldown 1 s
work-path hygiene 1 s bloated ordered deque

Dropped the second assign-after-free; window=1024 refills on the 50 ms assign.

Left alone on purpose: confirm drain/offer, FAR_SCAN_BUDGET / densify_scan_lo, event-driven header continuation, 5 s status scan, hard path reset, Direct-IBD skip of SH/tweaks.

Tests

  • ibd::cadence pins first-turn / period / inflight-empty / empty-path / bloat bypass
  • ordered_bloated + existing hygiene tests (hygiene always runs when called; caller cadences)
  • ibd_smoke

The 50ms sleep only fires when the loop is idle. Peer frames re-entered
the full housekeeping path at event rate: 64k densify scans,
locator_hashes header-table walks, relative-slow, and HashMap hygiene
competed with confirm.

Drain and confirm-offer stay event-driven. Assign ≤50ms (immediate if
inflight empty), header poll ≤500ms (empty path immediate), stall and
work-path hygiene ≤1s. Drop the second assign-after-free; 50ms refill
is enough for window=1024.
@reardencode
reardencode merged commit da10f04 into master Sep 3, 2026
13 checks passed
@rearden-grok
rearden-grok Bot deleted the ibd/tick-cadence branch September 4, 2026 15:09
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