Adding more threads to your code doesn't always speed things up—it can actually make them slower. In this first part of a two-part series, we explore why "parallel" doesn't mean "independent."
When multiple threads access the same shared data, the CPU often spends more time coordinating access—moving cache states, waiting on locks, and switching between tasks—than doing useful work. The result is code that looks busy but delivers less work per second.
Interestingly, the bottleneck isn't always the workload itself; it's the overhead of making workers share the same resources. This includes costs like cache coherence traffic, context switching, and lock contention.
Stay tuned for Part 2, where we'll dive deeper into thread vs. process trade-offs and practical tips for avoiding slowdowns.