Why we shouldn't use more threads than we need to
Overview There is a common argument that because we have lots of cores, and will have even more in the future we have to use them. We just we need to find the best ways to use them but just because we can doesn't mean we should. What is our goal? Good reasons to use multiple threads are the performance of using one thread is not enough. you have profiled your application to ensure there is no low hanging fruit. multiple threads improve the throughput, latency or consistency. At this point you should add a thread when you know it gets you closer to your goal. A bad reason to use multiple threads Just because we can use more threads doesn't mean we should. Multiple threads Adds complexity to the code There are other was to speed up an application. You L1 cache is 10-20x faster than you L3 cache and if you can spend more time in you L1 cache by optimising your memory usage and access, you can gain more performance than using every CPU in your socket. Mul