Assuming I wanted to (ab)use cache coherency to do lock free reads like FaRM, would it be enough to have a struct with a single 64 byte array as data to guarantee that on an architecture with 64 byte cache lines each struct would occupy exactly one cache line?
No, that wouldn't guarantee that the alignment was a cache line.
RFC 1358 added the concept of #[repr(align)]
, allowing the programmer to specify alignment requirements. This attribute was stabilized in Rust 1.25.
For your specific case, you'd use it like:
#[repr(align(64))]
struct Foo {
value: u8,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With