fix: pace block sync receives during response bursts - #907
Draft
czarcas7ic wants to merge 4 commits into
Draft
Conversation
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.
Motivation
Ordinary block sync can exhaust the receive message budget during a burst of block bodies and completion messages. The transport then closes a healthy connection, discarding useful in-flight work and forcing recovery. This still occurred on two clients in the eight-client validation after correcting fractional refill accounting.
Solution
Block-sync readers wait for shared message credit while retaining their current bounded frame. Rate and size limits remain enforced, FIFO admission preserves waiter order, and cancellation releases the waiter without consuming future credit. Other ordered streams retain their existing rejection behavior.
Testing
All 74 handler tests and all-target network Clippy passed on macOS, including a real QUIC worker test of outbound progress while receive admission waits. The final combined serving/pacing test revision passed all 1,191 Linux network tests (4 ignored) and all-target Clippy. The production-equivalent revision also passed its release build. Three existing tests in the expanded Mac suite require an unavailable loopback alias.
The eight-client native run reached every target without rate rejections or peer parks. In a separate genesis-sync pair, the baseline hit a rate rejection and disconnected; the candidate successfully paced 117 frames, averaging about 1 ms per wait, without a during-sync closure. Completion time was essentially unchanged at 236 seconds. Startup retries remain preserved, and broader qualification and production defaults are still pending.
Used Codex for implementation, tests and validation.