-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add rt-aware blocking semaphores in sys.rs, for use in exclusive ARCs #2795
Comments
also not sure how safe the cvar blocking path is. it'd need to be bulletproof if we're going to rely on it for linked failure |
Also they'd undoubtedly be slower, involving system calls in any contention path. Maybe having explicit runtime support would be better, if not too hard. |
For what it's worth, I got rid of newcomm.rs today, so you don't need to keep its needs in mind while designing this. See 604f7c6 |
This is done, on the way to completing #3145. |
…-obk Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC rust-lang#2795 mentioned this as a future possibility. This feature is [required](rust-lang#92137 (comment)) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](rust-lang#92137 (comment)). If someone could start a perf run and then a crater run this would be appreciated. Fixes rust-lang#92137
Exclusive ARCs currently use pthread mutexes directly (through lock_and_signal). Blocking on one of these will take the entire sched_loop offline until the mutex can be grabbed.
However, the runtime scheduler knows when a thread blocks on a lock_and_signal's associated condition variable, and can schedule other useful work.
If we built a semaphore on top of lock_and_signal + condition, then the semaphore could be used for mutual exclusion in a way that would let the scheduler do other useful work while a thread is blocked on one. Then it would be less bad to do an O(n) operation inside of an exclusive.
The downside is that no longer would the exclusive be able to pass through a condition variable, such as is needed in newcomm.rs. newcomm.rs is going away, but might something else need it?
The text was updated successfully, but these errors were encountered: