Core A and Core B each have a private L1 data cache with 64-byte cache lines. Core A repeatedly writes to a 32-bit integer variable X, while Core B repeatedly writes to a 32-bit integer variable Y. Both variables X and Y happen to be allocated adjacently in memory at addresses 0x1000 and 0x1004, respectively. What specific performance-degrading phenomenon occurs here, and how does the MESI protocol react?
This scenario describes "False Sharing." Although Core A and Core B are operating on completely independent variables, the variables reside in the same 64-byte cache block. When Core A writes to X, the MESI protocol marks the entire 64-byte cache line as Modified in Core A and Invalid in Core B. When Core B subsequently writes to Y, it suffers a coherence miss, forcing Core A to flush the line to memory (or forward it) so Core B can acquire it in the Modified state, invalidating Core A's copy. This back-and-forth invalidation causes severe bus traffic and latency, despite no actual data dependency.