-
Notifications
You must be signed in to change notification settings - Fork 349
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
Randomize thread unblocking operation #4032
Comments
Do real systems randomize? It may cause starvation, which is usually attempted to be avoided by having some order |
Generally we should be unblocking the thread that had waited the longest. Not sure what real systems do here, maybe we should ping some tokio folks who might know?
|
@rustbot label +A-shims
|
I wonder if the rules here are just the usual scheduler rules. Because at least on linux, according to https://www.man7.org/linux/man-pages/man7/sched.7.html the answer seems to be "unblock all threads and run them according to the normal scheduler rules" |
For For eventfd, since we are waking up all threads, would it makes sense to randomize the unblocking sequence, while still prioritizing threads that have been waiting the longest? I am still not sure what is the behaviour of actual system, though. |
If we can pull out the "pick next thread to resume from a list of thread ids" logic into a function, we can reuse it here. I'd like them to be the same logic, so if we change one, the other changes, too |
It would seems for |
In
eventfd
, we would unblock multiple threads in a deterministic sequence. Inepoll
, we always choose the thread id from the end of the list if multiple threads are blocked on the same epoll instance. We could randomize these operation depending on the seed.Related FIXME:
miri/src/shims/unix/linux/eventfd.rs
Lines 226 to 229 in 9d9da34
miri/src/shims/unix/linux/epoll.rs
Lines 549 to 555 in 9d9da34
Side note:
Blocking socketpair #3665 would need to use this too.
The text was updated successfully, but these errors were encountered: