[RFC] Add Optional Safe-to-Use Flavours of Mutex/CondVar#376
Closed
TheSven73 wants to merge 6 commits intoRust-for-Linux:rustfrom
Closed
[RFC] Add Optional Safe-to-Use Flavours of Mutex/CondVar#376TheSven73 wants to merge 6 commits intoRust-for-Linux:rustfrom
Mutex/CondVar#376TheSven73 wants to merge 6 commits intoRust-for-Linux:rustfrom
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 <thesven73@gmail.com>
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 <thesven73@gmail.com>
Just a preview of the Binder ping test.
Member
|
Review of
|
Member
|
I am currently investigating ways to improve ergonomics of my |
Member
|
This is what the code would look like with I think it looks pretty similar to boxed code except for some additional macros calls. |
Collaborator
Author
|
No consensus that this is worthwhile. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Request For Comments Only
Note that I am NOT proposing any changes to Binder
Our
MutexandCondVarabstractions push a lot ofPinreasoning 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
Pinthe 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
Mutexperformance, 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?