Are cache-line-ping-pong and false sharing the same?
Asked Answered
I

1

30

For my bachelor thesis I have to evaluate common problems on multicore systems.

In some books I have read about false sharing and in other books about cache-line-ping-pong. The specific problems sound very familiar, so are these the same problems but given other names? Can someone give me names of books which discuss these topics in detail? (I already have literature from Darry Glove, Tanenbaum,...)

Inconstant answered 6/6, 2015 at 16:18 Comment(0)
D
58

Summary:

False sharing and cache-line ping-ponging are related but not the same thing. False sharing can cause cache-line ping-ponging, but it is not the only possible cause since cache-line ping-ponging can also be caused by true sharing.

Details:

False sharing

False sharing occurs when different threads have data that is not shared in the program, but this data gets mapped to a cache line that is shared. For example imagine a program that had an array of integers where one thread performed reads and writes to all of the array entries with an even index, and the other thread performed reads and writes to entries with an odd index. In this case the threads would not actually be sharing data, but they would share cache lines since each cache line would contain both odd and even indexed values (assuming the cache line was bigger than an integer, which is typically true).

Cache-line ping-ponging

Cache line ping-ponging is the effect where a cache line is transferred between multiple CPUs (or cores) in rapid succession. This can be cause by either false or true sharing. Essentially if multiple CPUs are trying to read and write data in the same cache line then that cache line might have to be transferred between the two threads in rapid succession, and this can cause a significant performance degradation (possibly even worse performance than if a single thread were executing). False sharing can make this problem particularly difficult to detect, because a programmer might have tried to write an application so that the threads weren't sharing data, without realizing that the data was mapped to the same cache line. But false sharing is not the only possible cause of cache-line ping-ponging. This could also be caused by true sharing where multiple threads are trying to read and write the same data.

Devol answered 6/6, 2015 at 20:3 Comment(4)
Great answer. Thank you! Do you also have some recommondations for primary source literature , since referencing to stackvoerflwo is not a good beahviour?Inconstant
On reading the info about false sharing, I initially thought it was considered bad as the data that is not shared by the different threads might be modified concurrently by them which might results in some kind of improper update problem. To my surprise it seems to be the other way round! False sharing occurs when processors in a shared-memory parallel system make references to different data objects within the same coherence block (cache line or page), thereby inducing "unnecessary" coherence operations.Donnelldonnelly
Source : static.usenix.org/publications/library/proceedings/sedms4/…Donnelldonnelly
@kaartic: Right, we have cache coherency mechanisms to ensure that the program still runs correctly even with false sharing. Each core will exclusively own the cache line as it updates it. However this incurs a performance cost. Hence false sharing is a problem for performance, but not for correctness.Outwash

© 2022 - 2024 — McMap. All rights reserved.