A single line of code made a 24-core server slower than a laptop
&gt; The fact that our reference counters are atomic is an additional problem that makes things even more complex for the processor. Although using atomic instructions is often referred to as “lockless programming”, this is slightly misleading – in fact, atomic operations require some locking to happen at the hardware level. This locking is very fine-grained and cheap as long as there is no congestion, but as usual with locking, you may expect very poor performance if many things try to fight for the same lock at the same time. And it is of course much worse if those “things” are whole CPUs and not just single cores that are close to each other.<p>Contention is the devil and you can <i>never</i> hide from it if you bring it into your life. The fastest &quot;contention avoidance hack&quot; would be the CAS operation as mentioned above, which still performs approximately 2 orders of magnitude slower than a single threaded operation would in the most adverse scenarios.<p>If you aren&#x27;t sure of which problems actually &quot;fit&quot; on a modern x86 thread these days, rest assured that many developers in fintech have been able to squeeze entire financial exchanges onto one:<p><a href="https:&#x2F;&#x2F;lmax-exchange.github.io&#x2F;disruptor&#x2F;disruptor.html" rel="nofollow">https:&#x2F;&#x2F;lmax-exchange.github.io&#x2F;disruptor&#x2F;disruptor.html</a><p>For most scenarios, you really don&#x27;t need all those damn cores. They are almost certainly getting in the way of you solving your problems.