chore(lambda-runtime): slightly optimize graceful shutdown helper by using new tokio::try_join biased; api #1007
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.
✍️ Description of changes:
Closing out some minor to-dos. My tokio PR adding a biased; mode to join/try_join landed. This allows us to skip the bookkeeping of keeping track of which branch of a
join
/try_join!
statement was polled last, and always just poll in order.This is a minor optimization for our graceful shutdown handler, since we always want to just poll our graceful shutdown future first before our non-op extension. So we can save a bit of memory on the stack by skipping storing a usize. It also very marginally could impact latency (by micros if not nanos, it's insignificant probably).
Also applying a similar optimization to the internal extension example where we have it the extension wait until after the main handler completes so that it can flush telemetry.
This involved explicitly setting
tokio
to1.46
. This won't impact our MSRV as our MSRV is set to 1.81 but tokio is 1.70.🔏 By submitting this pull request
cargo +nightly fmt
.cargo clippy --fix
.