|
|
|
|
|
by staticassertion
1457 days ago
|
|
> you're often going to be better off eliminating the Arc/Mutex anyway Not always. Mutexes can be really fast (10-20ns), especially since they often optimistically spin, and Arc in Rust is (often) relatively low cost since you can hand out "free" refs without touching the atomic. If removing the Arc/Mutex would require allocations the Arc/Mutex could easily be faster. |
|
> Not always
Yeah, that's what "often" means.
> Mutexes can be really fast (10-20ns)
Notably, still worse than 0 ns. Ditto for Arc's refcounting and additional allocation. I'm not saying go on a crusade against Arc+Mutex here, but the easiest way to make effective use of modern multicore CPUS is to go to shared-nothing, independent data-per-thread designs (obviating Arc+Mutex). And if you aren't using Arc+Mutex, it's harder to accidentally share mutable state between threads.