4 ms·
Weird opening example. Trying to multi-thread a loop and then forcing everything through an atomic is worse than pointless: the atomic will effectively make it
by staplung 3y ago
Weird opening example. Trying to multi-thread a loop and then forcing everything through an atomic is worse than pointless: the atomic will effectively make it single-threaded anyway except now you have worse performance from cache non-locality, branch mis-prediction, and the overhead of using atomics. I get that it's just an example to show how the rust compiler can catch data-races but the section concludes "Moore's law is almost dead, at least for single core performance. Therefore, we need a language that makes concurrency not only easy, but also correct" without mentioning that many algorithms and procedures cannot be parallelized and that trying to force them to be will actually just make things worse.