Does sequential consistency implies cache coherence?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Sequential consistency and cache coherence are two fundamental concepts in the domain of multiprocessor systems, each addressing different aspects of memory behavior and performance. To fully appreciate whether sequential consistency implies cache coherence, it’s important to first understand these concepts individually and then explore their relationship.
Understanding Sequential Consistency
Sequential consistency is a model for describing the behavior of memory operations in multiprocessor systems. According to Lamport's definition, a system is sequentially consistent if the results of any execution are the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program. Essentially, this model guarantees that from the perspective of the programmer, memory operations appear to be instantaneously executed in the order they were issued, making programming and reasoning about concurrent operations much simpler.
Understanding Cache Coherence
Cache coherence, on the other hand, is a protocol used in multiprocessor systems to manage the multiple caches of a shared memory system. It ensures that any write operation to a data item in one cache is automatically propagated to other caches where the same data item might be stored. The main objective of cache coherence is to provide a consistent view of memory so that no stale data is read from any processor’s cache. This is typically managed through various protocols like MESI (Modified, Exclusive, Shared, Invalid), MOESI, MSI etc.
Does Sequential Consistency Imply Cache Coherence?
Sequential consistency concerns the global order of operations, while cache coherence deals with the visibility and consistency of individual memory writes across caches. Herein lies the answer: Sequential consistency does not automatically imply cache coherence. Sequential consistency is about the perception of operation ordering from the program’s point of view, ensuring that the interleave of program instructions across processors makes logical sense from the output.
However, this does not inherently solve the problem of maintaining a coherent view of memory at the hardware cache level, which is the role of cache coherence protocols. In simpler terms, even if every processor follows sequential consistency, it doesn’t necessarily mean they will see the latest update of a shared variable unless a cache coherence mechanism is in place. For instance, two processors can sequentially and consistently write to the same variable, but without cache coherence, one processor’s cache might end up with stale data.
The Role of Memory Barriers
To bridge the gap between these two concepts, memory barriers (also known as memory fences) are used. These are instructions used in processors to enforce an ordering constraint on memory operations issued before and after the barrier. They play a crucial role in achieving both sequential consistency and cache coherence in practical systems.
Example Scenario
Consider the following sequence of operations in a multiprocessor system without cache coherence:
- Processor A writes the value 1 to variable X.
- Processor B later reads variable X and then writes the value 2 to variable X.
- Processor A reads variable X.
Under sequential consistency, without appropriate cache coherence or memory barriers, Processor A’s second read might still see the initial value (1), not 2, if the caches haven’t been synchronized in between these operations.
Conclusion and Summary
Sequential consistency simplifies the mental model for programming on multiprocessor systems by focussing on the order of operations, whereas cache coherence ensures that all processors have a consistent view of shared data. The two concepts while related, address different parts of memory operation challenges in multithreaded environments.
| Concept | Focuses On |
| Sequential Consistency | Order of operations |
| Cache Coherence | Visibility and consistency of data across caches |
In practice, both are crucial for designing robust, predictable multiprocessor systems. Sequential consistency does not inherently include cache coherence, and typically both mechanisms need to be explicitly managed to ensure both correct ordering and data integrity across processor caches.
Related reading
- does slave-skip-errors avoid remove errors from the logs
- Does the Java Memory Model JSR-133 imply that entering a monitor flushes the CPU data caches?
- Does the number of consumer groups impact Kafka performance
- Does the row locking on slave database also apply to master database?
- Does this cause a real problem when I adopt the Raft's never commits log entries from previous terms by counting replicas rule in this situation?
- Doesn't Paxos end up with the same instructions in the exact same order?
- Domain Events and Commands in Distributed System (DDD)
- DTO and DAO concepts and MVC

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.