-
Notifications
You must be signed in to change notification settings - Fork 11
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
Bias UDP send loop towards the shutdown signal #372
Conversation
This is pretty wild. Even rewritten as its own async task, the UDP sender causes other tasks on the runtime not to be polled. a699c70 works around the issue by adding an explicit yield point. This is on my radar to min-repr and file upstream after further investigation. To repro with lading:
Here's the lading config I'm using: generator:
- udp:
seed: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]
addr: "127.0.0.1:10000"
variant: "json"
bytes_per_second: "500 Mb"
block_sizes: ["1Kb"]
maximum_prebuild_cache_size_bytes: "256 Mb"
blackhole:
- http:
binding_addr: "127.0.0.1:9091" |
Dang. Getting upstream consideration of this would be excellent. I have wondered now and again if we might not profitably split lading's internals up so that each component runs on a single-threaded executor on top of an OS thread we manage from startup. We'd get better isolation, at least, for things like this. Non-trivial change, but it's crossed my mind now and again. |
@@ -149,6 +149,7 @@ impl Udp { | |||
"UDP packet too large (over 65507 B)" | |||
); | |||
if let Some(sock) = &connection { | |||
tokio::task::yield_now().await; |
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 guess at-speed we always have bytes ready, considering the size of the max payload. Hrm.
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.
What's wild to me is that we have cores - 1
tokio worker threads sitting idle while this is happening. This should be very interesting to min-repr and dig into.
My initial thought is that we only have one task active. Maybe tokio tries to squeeze in its scheduling at a low priority after workers go idle. That could lead to exactly this situation.
@blt sorry for the review re-request, I missed your comments earlier |
This issue has me thinking about the same thing. Either a separate OS thread or another tokio runtime on its own pool of threads. |
There's a lot to be said for the performance of a shared-nothing program with tasks broken down per-thread running on a single OS thread, assuming we know that the threads are dedicated to a busy bit of work. |
What does this PR do?
We've observed an issue where the UDP generator will run forever, ignoring the shutdown signal. This PR biases the UDP generation task towards polling the shutdown signal to avoid this.
Motivation
Stop
lading
processes from spinning on UDP forever.Related issues
N/A
Additional Notes
We may consider refactoring shutdown to abort async tasks rather than signal and expect cooperation.