Repository navigation
Conversation
This branch has not been deployed
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.
Problem
Fixes hyperium/hyper#4245
In the legacy client connection pool, every dropped
Checkoutwith a parked waiter triggersclean_waiters, which runsVecDeque::retainover the entire waiter queue for that key while holding the pool lock. With n parked waiters this is O(n^2) total work — the reporter measured 10.5s for 131,072 concurrent requests against a cold pool.Fix
putalready skips canceled waiters lazily (tx.is_canceled()+pop_front), so the eager full scan on drop is redundant.clean_waitersnow only pops the canceled prefix of the queue: each parked sender is popped at most once, making cleanup amortized O(1) per drop. The key entry is still removed once the queue is empty, so the observable cleanup contract is unchanged (test_pool_checkout_drop_cleans_up_waiterspasses unmodified).Verification
cargo test --all-features --lib: 107 passed, 0 failed (includes 2 new regression tests: bulk drop cleanup, and out-of-order drop followed byputstill waking the live waiter).cargo fmt --all --check: clean.