ibd: skip empty-lag store reseed while the work path is live - #314
Merged
Conversation
Empty getheaders while peers advertise ahead kept calling seed_work_path_from_store (full header-graph walk, ~0.5–1.2s) every 64 empties. Latter mainnet IBD did that ~1800 times in an hour while ordered already held 12k–64k hashes. Reseed only when ordered is empty. Keep re-getheaders. Drop the WARN to trace unless the path is empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Latest mainnet IBD (
mainnet.log, 2026-09-03 01:28–02:34) logged ~1800WARN ibd: empty headers but lag=870…940lines, about one every 2s, whileconfirm ran tip 901k → 953k.
Those WARNs are not the cost. The same cadence calls
seed_work_path_from_store→resume_work_path_after_tip, which scans everyheader in the store (~1M). The matching
resume seed walklines were:orderedalready 12k–64kknown≈965240stuck the whole hour (lag stayed ~870–940)That is ~15–30 minutes of IBD-thread time spent rebuilding a path we already
held. Empty
getheaderswhile peers advertise ahead is expected (locator atheader HWM / peer LastBlock skew). Re-ask is cheap; the store walk is not.
Change
ordered_setis empty (no locator tips).getheaderscadence (every 8 empties).WARNonly if the path is empty; otherwisetrace.Test
ibd::exit::tests::empty_headers_lag_rate_limitsnow pins: live ordered pathnever reseeds at streak 1/64/128; empty path still reseeds at 1 and 64.