Multi-Core By Default - by Ryan Fleury - Digital Grove
Posted by fagnerbrack@reddit | programming | View on Reddit | 5 comments
Posted by fagnerbrack@reddit | programming | View on Reddit | 5 comments
Own-Avocado-2876@reddit
Herb Sutter called this "The Free Lunch Is Over" back in 2005. Twenty years later, most codebases still treat parallelism as an afterthought. Amdahl's Law doesn't care about your feelings -- if 10% of your code is serial, 100 cores still only give you 10x speedup. The real unlock isn't more threads, it's data-oriented design that eliminates shared state. Mike Acton's "Data-Oriented Design and C++" talk should be required viewing.
teerre@reddit
This post just brushes off synchronization and caching. For a trivial example like this yes, it's fine, but in practice this is much more complicated. This really only covers the "embarrassingly parallel" algorithms, which are the exception, not the rule. If you were to generalize this, you would end up with something like https://github.com/NVIDIA/cccl/tree/main/thrust, which you can click around for a bit and see it's far from trivial
Also, cache aligned densely packed data is what CPUs were created for, very often, maybe always, you'll get much better performance by properly organizing your data in such way the CPU can use its caches to their fullest than just throwing threads at it (of course, you can do both)
gitsad@reddit
but multi-core is harder than single-core. That's why it's easier to make it, test it and then eventually change it
Sopel97@reddit
what's actually hard is fixing performance of single-threaded code from people who think like you
gitsad@reddit
But I'm not talking about fixing performance. Many products just die before reaching any users so no perfomance bottlenecks are even found. Managing one thing instead of multiple is always simpler. If you are creating a game or any sophisticated thing that needs multi-core at first place that's fine. Many products at the beginning are over engineered that's why there is a rule to simplify things when doing some PoC/MVP. Do your multi-core if you want. It doesn't change the main thing that multi-core needs more management than single-core