Skip to content

fix(swarm): bound Connection::poll iterations for cooperative scheduling#6513

Open
akshitj11 wants to merge 1 commit into
libp2p:masterfrom
akshitj11:fix/6438-connection-poll-budget
Open

fix(swarm): bound Connection::poll iterations for cooperative scheduling#6513
akshitj11 wants to merge 1 commit into
libp2p:masterfrom
akshitj11:fix/6438-connection-poll-budget

Conversation

@akshitj11

Copy link
Copy Markdown

Summary

  • Bound Connection::poll fixed-point loop iterations to avoid long polls that starve Tokio workers.
  • Self-wake on budget exhaustion so connections with pending internal work are rescheduled promptly.

Fixes #6438

Test plan

  • Pre-change invariants documented (stall/wake, Ready-path bypass, multi-poll equivalence)
  • cargo test -p libp2p-swarm
  • cargo clippy -p libp2p-swarm --all-features --no-deps
  • m15 anti-pattern review — poll contract + unbounded loop checks
  • Bugbot review — no stall/regression findings
  • Security review — event ordering unchanged

Cap the fixed-point loop in Connection::poll with a 128-iteration budget
and self-wake on exhaustion so Tokio workers are not monopolized during
large muxer/handler progress bursts.

Fixes libp2p#6438
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.

swarm: Connection::poll regularly exceeds Tokio's 50 µs slow-poll threshold

1 participant