Repository navigation
perf(pool): keep Singleton waiters in a Slab - #353
Merged
seanmonstar merged 6 commits intoNov 18, 2026
Merged
seanmonstar merged 6 commits into
seanmonstar merged 6 commits into
Conversation
Batch::store_waker and Batch::remove looked a waiter up with a linear scan under the lock. When many requests wait on the first connection that's O(n) per poll; polling 30k waiters once took ~150ms. A map keyed by WaiterId makes both lookups O(log n), ~1ms for the same run. Driver hand-off still promotes the newest waiter, as Vec::pop did.
Member
|
Interesting! I'd be interested in hearing about use cases, was this found by having a case where there were 30k requests queued? |
Contributor
Author
|
I didn't have a use case. I'm just interested in optimizing things. Anything I can improve here? |
Member
|
Hm, would using a |
Contributor
Author
|
Thanks for pointing me to
|
seanmonstar
requested changes
Nov 18, 2026
| tower-layer = { version = "0.3", optional = true } | ||
| tower-service = { version = "0.3", optional = true } | ||
| sync_wrapper = { version = "1", optional = true } | ||
| slab = { version = "0.4", optional = true } |
Member
There was a problem hiding this comment.
I think we need to set the minimum version to 0.4.4, because of using try_remove.
seanmonstar
approved these changes
Nov 18, 2026
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.
Batch::store_waker and Batch::remove looked a waiter up with a linear scan under the lock. When many requests wait on the first connection that's O(n) per poll; polling 30k waiters once took ~150ms.
A map keyed by WaiterId makes both lookups O(log n), ~1ms for the same run. Driver hand-off still promotes the newest waiter, as Vec::pop did.