6.824 2015 Lecture 9: DSM and Sequential Consistency

Note: These lecture notes were slightly modified from the ones posted on the 6.824 course website from Spring 2015.

Topic: Distributed computing

Distributed Shared Memory (DSM) programming model

Challenge: distributed systems don't have physical shared memory

Diagram:

    *----------*   *----------*   *----------*
    |          |   |          |   |          |
    |          |   |          |   |          |
    |          |   |          |   |          |
    *-----*----*   *-----*----*   *-----*----*
          |              |              |
  --------*--------------*--------------*-------- LAN

Diagram:

         M0             M1
    *----------*   *----------*   
    | M0 acces |   | x x x x  |   
    |----------|   |----------|
    | x x x x  |   | M1 acces |   
    *-----*----*   *-----*----*   
          |              |        
  --------*--------------*------- LAN

  The 'xxxxx' pages are not accesible locally,
  they have to be fetched via the network

Approach:

Challenges:

Correctness: coherence

Example 1:

  x and y start out = 0

  M0:
    x = 1
    if y == 0:
      print yes
  M1:
    y = 1
    if x == 0:
      print yes

  Can they both print "yes"?

Naive distributed shared memory

Diagram 1:

Does this naive memory work well?

Diagram (broken scheme):

         M0
    *----------*   *----------*   *----------*
    |          |   |          |   |          |
    |        ------------------------> wAx   |
    |        ----------> wAx  |   |          |
    *-----*----*   *-----*----*   *-----*----*
          |              |              |
  --------*--------------*--------------*-------- LAN

Coherence = sequential consistency

Would sequential consistency cause our example to get the intuitive result?

Sequence:

  M0: Wx1 Ry?
  M1: Wy1 Rx?

Go's memory consistency model

Example:

x = 1
y = 2

A simple implementation of sequential consistency

A straightforward way to get sequential consistency: Just have a manager in between the two or three machines that interleaves their instructions

    *----------*   *----------*   
    |          |   |          |   
    |          |   |          |   
    |          |   |          |   
    *-----*----*   *-----*----*   
          |              |        
  --------*--------------*--------
                 |
                 |
           *----------*
           | inter-   |
           | leaver   |
           |          |
           *-----*----*
                 |
                -*-
                \ /
                 .
                RAM

Diagram 2:

    *----------*   *----------*   
    |          |   |          |   
    |          |   |          |   
    |          |   |          |   
    *-----*----*   *-----*----*   
          |              |        
  --------*--------------*--------
                 |
                 |
           *----------*
           |          |
           |          |
           |          |
           *-----*----*
                 |
                -*-
                \ /
                 .
                RAM

This simple implementation will be slow

Which brings us to IVY

IVY big picture

  [diagram: M0 w/ a few pages of mem, M1 w/ a few pages, LAN]

Invariant:

IVY allows multiple reader copies between writes

Why crucial to invalidate all copies before write?

How does IVY do on the example?

Message types:

(see ivy-code.txt on web site)

Scenario 1: M0 has writeable copy, M1 wants to read

Diagram 3:

  [time diagram: M 0 1]
  1. M1 tries to read gets a page fault
  2. M1 sends RQ to MGR
  3. MGR sends RF to M0, MGR adds M1 to copy_set
  4. M0 marks page as $access = read$, sends RD to M1
  5. M1 marks $access = read$, sends RC to MGR

Scenario 2: now M2 wants to write

Diagram 4:

  [time diagram: M 0 1 2]
  1. Page fault on M2
  2. M2 sends WQ to MGR
  3. MGR sends IV to copy_set (i.e. M1)
  4. M1 sends IC msg to MGR
  5. MGR sends WF to M0, sets owner=M2, copy_set={}
  6. M0 sends WD to M2, access=none
  7. M2 marks r/w, sends WC to MGR

Q: What if two machines want to write the same page at the same time?

Q: What if one machine reads just as ownership is changing hands?

Does IVY provide strict consistency?

What if there were no IC message?

TODO: What is IC?

No WC?

TODO: What is WC?

What if there were no RC message?

In what situations will IVY perform well?

  1. Page read by many machines, written by none
  2. Page written by just one machine at a time, not used at all by others

Cool that IVY moves pages around in response to changing use patterns

Will page size of e.g. 4096 bytes be good or bad?

What about IVY's performance?

What's the best we could hope for in terms of performance?

What might prevent us from getting $N \times$ speedup?

How well do they do?

Why did sort do poorly?

How could one speed up IVY?

Paper intro says DSM subsumes RPC -- is that true?

Known problems in Section 3.1 pseudo-code