News for hackers. Stuff that matters.
Re:Distributed systems in an alternative universe by scott_s on Wednesday March 09, 2016 @10:40AM (#11253540)
It applies at the socket level as well: modern systems with many sockets (physical processor chips) are like to be NUMA (https://en.wikipedia.org/wiki/Non-uniform_memory_access), or non-uniform memory access systems. That means that there is a performance benefit if you access memory on your local NUMA node.

And irrespective of NUMA, it also applies to data sharing between threads: if you have a system with 100s of threads, but you have a multithreaded application written like this:

    while (globalFlag) {
        doSomeLightWork();
    }
Your application will not scale well. The cost of 100s of threads all accessing globalFlag will dominate performance, as the cache line for that variable bounces around the entire system.

All systems are becoming "distributed systems". Even though a single machine will get more and more beefy, we will still have to apply distributed systems thinking in order to take full advantage of that system.

Re:Distributed systems in an alternative universe by api on Wednesday March 09, 2016 @11:02AM (#11253705)
A chip is a distributed system of transistors too. It's all a matter of scale. The CAP theorem applies there too. Discrete systems choose CA over P, which is why they crash (loss of A) if any single part of them is partitioned in any way.
Re:Distributed systems in an alternative universe by hga on Wednesday March 09, 2016 @11:55AM (#11254033)
As I understand it, they're officially considered to be a type of NUMA, cache coherent NUMA or ccNUMA: https://en.wikipedia.org/wiki/Non-uniform_memory_access#Cach...
Re:Distributed systems in an alternative universe by Rusky on Wednesday March 09, 2016 @01:00PM (#11254511)
Wouldn't globalFlag just be shared in a duplicated cache line between all cores until one of them modifies it?
Re:Distributed systems in an alternative universe by scott_s on Wednesday March 09, 2016 @02:30PM (#11255163)
If the code was:

    while (globalFlag) {
        ++someValue;
    }
Then you'd probably be okay. But calling a function which does some lightweight but non-trivial work will interfere with your cache. When you come back from the stack frame for doSomeLightWork(), you're more likely to need to load globalFlag from memory.

In a multithreaded application where you want to scale to dozens or even hundreds of threads, you have look at even global memory accesses as communication.

Re:Distributed systems in an alternative universe by Rusky on Wednesday March 09, 2016 @05:07PM (#11256063)
That still doesn't sound like the cache line "bouncing around" any more than it would if a single-core app did the same work. There's no contention on it the way there would be on a shared mutable value, at least.
Re:Distributed systems in an alternative universe by scott_s on Wednesday March 09, 2016 @06:03PM (#11256330)
There is still contention, but not as much. With, say, 8 threads it probably doesn't matter much. But with 128, it starts to matter.