See if unordered atomics are a feasible replacement for DisjointMut
's potential unsoundness
#1359
Labels
low priority
Issues that we would like to address at some point in the future
performance
safety/correctness
In a discussion of
DisjointMut
and its potential unsoundness (if there are any overlapping ranges in--release
mode) on Reddit, u/afdbcreid suggested suggestedUnordered
atomics as a potential performant solution, as discussed on IRLO:unordered
as a solution to “Bit-wise reasoning for atomic accesses”.The only other potentially performant option we saw was to use
Relaxed
atomics. However, evenRelaxed
atomics are not optimized the same way in aggregate. An individualRelaxed
load and store is the same instruction as aNotAtomic
load and store, but, for example, 2 16-bit alignedAtomicU8
loads are not merged into a singleAtomicU16
load. However, in LLVM's atomics model, there is a level betweenNotAtomic
andRelaxed
/Monotonic
calledUnordered
. It is used by Java primarily and has even fewer guarantees compared toRelaxed
/Monotonic
, and as such, LLVM will do those same merging optimizations that we want. As such, it's possible it would result in good enough performance. However,Unordered
is not in stable Rust, and is only an unstable intrinsic at the moment: good enough for some experimentation if we want to try it out, but far from stable. And fully trying it out, along with all of the necessary refactoring, and then evaluating performance would be significant work. Ideally, we'd try in the name of soundness, though time is a concern.The text was updated successfully, but these errors were encountered: