-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update linkerd2-cache and linkerd2-lock to std::future #490
Conversation
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
This branch updates the `concurrency-limit` middleware to std::future. The new implementation uses the new owned semaphore permit API added in Tokio 0.2.19 (tokio-rs/tokio#2421). Similarly to #490, the old implementation could not be directly translated due to `tokio::sync`'s `Semaphore` losing its `poll`-based API in 0.2. Signed-off-by: Eliza Weisman <[email protected]>
This branch updates the `concurrency-limit` middleware to std::future. The new implementation uses the new owned semaphore permit API added in Tokio 0.2.19 (tokio-rs/tokio#2421). Similarly to #490, the old implementation could not be directly translated due to `tokio::sync`'s `Semaphore` losing its `poll`-based API in 0.2. Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
@hawkw looks like Cargo.lock is out of date? |
@@ -44,7 +44,7 @@ tower = "0.1" | |||
tower-grpc = { version = "0.1", default-features = false, features = ["protobuf"] } | |||
tracing = "0.1.9" | |||
tracing-futures = "0.1" | |||
webpki = "0.21" | |||
webpki = "=0.21.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, i published an updated version of our fork a while ago https://github.com/linkerd/webpki/tree/cert-dns-names-0.21
@hawkw Would we still need the specialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this merging when it's green. I think, ideally, we ought to get rid of our lock implementation.... but that's not a blocker.
If we wanted to use Tokio's |
@hawkw I'd have to check to confirm, but I believe we wrap all of these with |
This branch updates the `concurrency-limit` middleware to std::future. The new implementation uses the new owned semaphore permit API added in Tokio 0.2.19 (tokio-rs/tokio#2421). Similarly to #490, the old implementation could not be directly translated due to `tokio::sync`'s `Semaphore` losing its `poll`-based API in 0.2. Signed-off-by: Eliza Weisman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Cargo.lock
still needs to be updated but changes look good!
tokio-rs/tokio#2455 merged upstream, so we could definitely do this. Also, we can now remove all the |
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, modulo the unrelated comment change
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
This branch updates the
linkerd2-cache
crate (andlinkerd2-lock
,which it relies on), to use
std::future
.Unlike previous PRs, the
linkerd2-lock
update is a more substantialrewrite, because upstream API changes made the previous implementation
no longer possible. In particular,
tokio::sync::Mutex
does not providea
poll_acquire
method the way thattokio_sync::Lock
did in Tokio0.1. The removal of
poll_acquire
is largely due to the rewrite ofTokio's synchronization primitives to use an intrusive linked list-based
semaphore (tokio-rs/tokio#2325), which requires waiters to be pinned to
ensure safety of the intrusive list. Allowing permits to be acquired
only from a future ensures correct pinning of waiters.
Therefore, I've implemented a new
Lock
for Linkerd which uses a TokioSemaphore
with 1 permit to ensure exclusive access. TheLock
owns aboxed instance of the future returned by
Semaphore::acquire
, anddrives it in
poll_acquire
. This allows adapting the poll-based Towerinterface with the futures-only, pinned interface.