-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add cache line size padding to RWLock #117519
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
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
Insufficient permissions to issue commands to rust-timer. |
@mj10021: 🔑 Insufficient privileges: not in try users |
@bors try @rust-timer queue |
Add cache line size padding to RWLock Fixing issue rust-lang#117470, this PR just copies the `cfg_attr` `repr` from the cache padding crate to stop RWLocks from sharing cache lines.
☀️ Try build successful - checks-actions |
We have a |
Alternatively, it might make more sense for the original reporter to wrap their own |
Yeah that makes sense to me since its a pretty simple optimization on a case by case basis. Would it make sense to mention in the RWLock docs that padding to cache line size can be a known speed optomization? |
Going one step further, maybe the std should provide the |
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.
repr(align(n))
doesn't work here. Inside the structure it requires something like:
struct RwLock<T> {
inner : CachePadded<RwLock>,
...
}
But std seems not support such kind yet.
As others have already commented, making these locks this big for everyone seems like a big pessimization if the locks aren't in a really hot path next to each other. |
Fixing issue #117470, this PR just copies the
cfg_attr
repr
from the cache padding crate to stop RWLocks from sharing cache lines.