-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
io: add budgeting to tokio::runtime::io::registration::async_io #6221
Conversation
05775ab
to
4c8b4b5
Compare
4c8b4b5
to
aa9839d
Compare
Note: this is being backported, so do not merge. I will merge it manually on the command line. |
tokio/src/runtime/io/registration.rs
Outdated
let coop = crate::future::poll_fn(crate::runtime::coop::poll_proceed).await; | ||
|
||
match f() { | ||
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { | ||
self.clear_readiness(event); | ||
} | ||
x => return x, | ||
x => { | ||
coop.made_progress(); | ||
|
||
return x; |
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.
This affects only things that use async_io
. I believe that we discussed a different fix on one of the issues, which is the following:
- Polling for readiness returns Pending on missing coop budget, but does not consume budget.
- IO operations, even non-async ones, consume a budget, but do not check it.
With the above change, async_io
would get the right behavior automatically.
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.
This feels like the correct way to do the accounting, but I'm worried it might lead to more significant changes in behavior than we may intend (e.g many users might be expecting try_ ops to not touch the buget).
Perhaps we can use this current method for the patch releases, and then the other method for the next minor version release we do?
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.
That works for me.
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.
This version is ok for the backports to LTSs.
Fixes #5946. Fixes #4782. This change adds budgeting to most of the remaining unbudgeted IO operations which can complete instantly, including datagram send/recv operations and listener socket accepts. This is particularly significant for scenarios in which resource limits are hit, as it can be common for things like listener tasks to spin when receiving errors and just log them, busy looping worker threads which might otherwise be handling existing connections and closing them. This can also sometimes lead to complex failure scenarios within datagram systems experiencing resource exhaustion.
d12d34f
to
7a64ff0
Compare
@@ -0,0 +1,77 @@ | |||
#![warn(rust_2018_idioms)] |
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.
Should this file be called core_budger.rs
? Should it not be core_budget.rs
(notice the "t" at the end and not "r")?
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.
Ah, nice catch. Do you want to submit a PR that fixes it?
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.
Admittedly not, my apologies. Just a drive-by observation as I am clocking out of work.
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.
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.
once again, the keyboard on the new laptop has bested me
Bumps tokio from 1.35.0 to 1.35.1. Release notes Sourced from tokio's releases. Tokio v1.35.1 1.35.1 (December 19, 2023) This is a forward part of a change that was backported to 1.25.3. Fixed io: add budgeting to tokio::runtime::io::registration::async_io (#6221) #6221: tokio-rs/tokio#6221 Commits 46ff363 chore: prepare Tokio v1.35.1 (#6230) 0a1695e Merge 'tokio-1.32.1' into 'tokio-1.35.x' (#6229) c4f0178 chore: prepare Tokio v1.32.1 (#6228) 22b3a65 Merge 'tokio-1.25.3' into 'tokio-1.32.x' (#6227) 0d36233 chore: release v1.25.3 (#6223) ab7313f io: add budgeting to tokio::runtime::io::registration::async_io (#6221) See full diff in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot merge will merge this PR after your CI passes on it @dependabot squash and merge will squash and merge this PR after your CI passes on it @dependabot cancel merge will cancel a previously requested merge and block automerging @dependabot reopen will reopen this PR if it is closed @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Fixes #5946.
Fixes #4782.
This change adds budgeting to most of the remaining unbudgeted IO operations which can complete instantly, including datagram send/recv operations and listener socket accepts.
This is particularly significant for scenarios in which resource limits are hit, as it can be common for things like listener tasks to spin when receiving errors and just log them, busy looping worker threads which might otherwise be handling existing connections and closing them.
This can also sometimes lead to complex failure scenarios within datagram systems experiencing resource exhaustion.