-
Notifications
You must be signed in to change notification settings - Fork 434
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
[RFC] Add Optional Safe-to-Use Flavours of Mutex
/CondVar
#376
[RFC] Add Optional Safe-to-Use Flavours of Mutex
/CondVar
#376
Conversation
Introduce `Boxed` flavours of `Mutex` and `CondVar`. These flavours do not force users to keep them `Pin`ned. Which means users no longer need to make complex `Pin` inferences, or use `unsafe` blocks simply to use `Mutex` or `CondVar`. Signed-off-by: Sven Van Asbroeck <[email protected]>
Replace all Mutexes and CondVars in Binder with their Boxed flavours, for the purpose of running Wedson's Binder benchmark. Note that this should allow elimination of many `Pin`ned structs in Binder. But I have not attempted that, as unnecessary `Pin`ning should not influence benchmark performance. Signed-off-by: Sven Van Asbroeck <[email protected]>
Just a preview of the Binder ping test.
Review of
|
I am currently investigating ways to improve ergonomics of my |
This is what the code would look like with I think it looks pretty similar to boxed code except for some additional macros calls. |
No consensus that this is worthwhile. |
Request For Comments Only
Note that I am NOT proposing any changes to Binder
Our
Mutex
andCondVar
abstractions push a lot ofPin
reasoning and unsafe blocks onto its users. This creates plenty of rope for less experienced driver writers to hang themselves, and is therefore not necessarily an improvement over C.Try this one on for size:
linux/samples/rust/rust_miscdev.rs
Lines 40 to 56 in 5dd07d5
The proposed Optional Safe-to-Use flavours reduce this complexity, without requiring code changes anywhere else:
(actually code complexity will be reduced further, as there is no longer a need to
Pin
the returned structure)The downside here is, obviously, the extra heap allocations, heap dereferences and loss of cache locality. But we only guess these are problematic. How can we verify that in the real world?
Turns out that @wedsonaf's proposed Binder ping benchmark appears quite sensitive to
Mutex
performance, as witnessed by the fact that we can measure a regression when adding one extra function call overhead toMutex::lock
. See:#346 (comment)
#346 (comment)
So I regression tested Wedson's benchmark on arm 32-bit (cortex-a9 + Raspberri Pi Zero) and... no apparent change in performance.
Perhaps we will see a performance regression on x86 or RISC-V? If so, are the safety gains worth it?