Previous | Next --- Slide 52 of 56
Back to Lecture Thumbnails

Do compilers for higher-level languages without direct memory control typically use techniques like this?


In summary, false sharing occurs if you have two functions running concurrently, that say Program A uses a and Program B uses b, where a and b are from the same cache line. Program A never writes to b, and neither does Program B write to A. Our granularity here is per cache line. Therefore, even though the accesses don't affect each other, each time, the programs will read from main memory, instead of cache.


@xyz I would personally hold back from applying this "optimization" automatically. The reason is that the memory overhead for this case is, for example, 64KB / 4B = 16000!

I actually went online and look for if Java applies this padding, and stumbled upon this article:

It seems that Java does not apply the padding automatically, and due to memory overhead I don't think compilers should do it by themselves.