in reply to Re^2: Threading vs perl
in thread Threading vs perl

You were taught correctly. For which reason good schedulers go out of their way to keep threads in a process on a single CPU.

In fact SMP has a fundamental major flaw, which is that it does not scale. As you add more CPUs, each CPU spends a larger portion of its time waiting for all CPUs to come to attention so that one can do something which needs to avoid a race with any other. Eventually the useful work done by the next CPU is less than the amount of time it causes others to waste. This is the computer version of an organization where everyone spends all of their time in meetings. By breaking things into many smaller locks, and making sure that each CPU checks in more frequently, you can improve this. However this adds overhead, and you get diminishing returns. The best that I know of offhand is 128, and the last 64 CPUs don't add much.

To really scale you need to move to NUMA (Non-Uniform Memory Architecture). In this architecture CPUs organize into groups, so when one needs others to synchronize it only needs some other CPUs to synchronize, reducing this locking considerably. This is the computer version of moving from a perfectly flat to a hierarchical organization.