How cache coherence affects performance in this case

Let's say if kernel A modifies a variable X, and kernel B reads that variable (X). Of course, in this case, the cache coherence protocol will update the core B cache because X has been changed by the A core, and, of course, this cache coherence will slow down the execution on the B core. However, this cache coherence will also affect the performance of the A core, assuming that the variable X is in its cache.

+6
source share
2 answers

Yes. There are several ways to affect performance. The standard protocol that the user uses is some version of MSI (Modified, Shared, Invalid), sometimes with O (Owner) and often E (Exclusive) added to the protocol. In your example, core A will start in the Modified (or Exceptional) state, and reading basically B will force core A to change it to Shared state. This action takes cycles in the cache, since there are only so many operations that the kernel can perform at any given time. The impact of this on Core A is not very large, as it is not in a critical way. What is more influential is what Core A writes again. Since the cache line is in general (or invalid) state, it should issue a request to upgrade to M or E. This request should go to kernel B. This operation is on a critical path, and the write cannot complete until the cache block is updated. However, records are usually buffered, and the processor is usually not blocked during this operation.

+3
source

Yes, on modern microarchitectures using ME (O) SI consistency protocols, it will slow down updates from A to X The reason for this is that reading B will put the cache line containing X in the "shared" state before copying it, and then A write will be forced to invalidate the copy of B to enter the "exclusive" state before it can change it again .

With everything said, A writes to X , it may not stop the execution pipeline. It depends on the model of consistency of memory architecture and programming language, and on whether the record is called as an atomic operation or subsequent capture of the record.

+2
source

Source: https://habr.com/ru/post/912659/


All Articles