How does Distributed Shared Memory work in the presence of cache and registers?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Distributed Shared Memory (DSM) is an abstraction in distributed computing to create a virtual shared memory across systems that do not physically share memory. DSM systems enable processes on different nodes of a distributed system to share data as if they were running on a single multi-processor with shared memory. This facilitates easier program development and contributes to scalability in distributed systems. However, integrating DSM systems in the presence of each node's local caches and registers introduces complexity, particularly regarding data consistency and performance.
How Distributed Shared Memory Works
DSM operates by managing a shared memory space which could be implemented via software or hardware approaches, or a combination of both. The memory is divided into pages or blocks, which are distributed among the various nodes. Each page can be replicated locally to improve performance and reduce access latency.
Challenges with Cache and Registers
- Cache Coherence:
- Issue: When local caches store frequently accessed data, multiple cached copies of the same data can lead to inconsistencies if not managed properly.
- Solution: DSM systems commonly implement cache coherence protocols that ensure consistency across the nodes. Examples include write-invalidate and write-update protocols.
- Registers:
- Issue: Registers, which are used for storing temporary data for processing, do not directly impact DSM; however, data loaded from DSM into registers must be managed to maintain consistency once written back to memory.
- Solution: Similar to cache coherence, mechanisms are needed to ensure that register changes are propagated back to the DSM and consequently to other nodes' caches if necessary.
Types of DSM Systems
- Page-based DSM: Delays updates until a page is replaced, reducing the number of update messages needed at the cost of possible stale data.
- Object-based DSM: Provides a finer-grained consistency control by focusing on shared objects rather than memory pages.
- Home-based DSM: Designates a home node for each shared page or object, centralizing control but potentially creating hotspots.
Cache Coherence Protocols
Several protocols exist to manage how data is updated across the distributed system to ensure consistency:
- Write-Invalidate: On a write operation, all other caches containing that page are invalidated. Future reads require fetching the data again, ensuring that all nodes see the latest write.
- Write-Update: On a write operation, an update is sent to all nodes that holds a cached copy of the page. This method reduces read latency at the cost of increased network traffic.
Examples in Operating Systems
Operating systems like MOSIX and distributed implementations of UNIX, such as Mach, have implemented forms of DSM to test the feasibility and performance implications in real operational environments.
Technical Table
| Feature | Definition | Implications |
| DSM | Distribution of shared memory across multiple nodes | Eases application development and improves modularity |
| Cache Coherence | Protocols to maintain consistency of data cached locally at different nodes | Critical for data consistency, affects performance and scalability |
| Write-Invalidate | Cache coherence protocol where writes invalidate cached copies | Ensures consistency but may increase load times for fresh reads |
| Write-Update | Cache coherence protocol where writes update all cached copies | Minimizes read latency but increases network traffic |
| Page-based DSM | Management of sharing at the memory page level | Can lead to less frequent updates but possible data staleness |
| Object-based DSM | Management of sharing at the object level | Allows fine-grained control and potentially better performance in object-heavy use cases |
Conclusion
Understanding and implementing DSM in the presence of cache and registers offers the potential to radically enhance the performance and scalability of distributed systems. However, it requires careful consideration of coherence strategies and systems architecture to ensure data consistency and system efficiency. The ongoing development in this field continues to address these challenges, reflecting its importance and potential in distributed computing environments.
Related reading
- How does distributed tensorflow work ? Issue with tf.train.Server
- How does Elasticsearch recover from a quorum that is not unanimous
- How does Erlang's support for transparent distribution of actors impact application design?
- How does etcd propagate writes to non-leader members?
- How does docker image size impact runtime characteristics?
- How does Git save space and is fast at the same time?
- How does fault tolerance works in a distributed system?
- How does Google file system deal with write failures at replicas?

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.