Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Virtual Time

raven
November 18, 2019

Virtual Time

Presentation about DAVID R. JEFFERSON's paper: "Virtual Time"

raven

November 18, 2019
Tweet

More Decks by raven

Other Decks in Programming

Transcript

  1. Basic Data • Type of paper: propose new paradigm on

    distributed system. • Authors’ institutions: University of Southern California • Funded by: Jet Propulsion Laboratory(NASA) • Appear in: ACM Trans. Prog. Lang. Syst. 2
  2. The Ideas Proposed Virtual Time and Time Warp mechanism. Virtual

    Time is new paradigm for synchronization mechanism in distributed system. Time Warp is implementation for it. Most mechanism(locks, semaphores,…) based on “block-resume” or “atomic action”, but new mechanism based on “rollback”. 3
  3. Key Quotes • "To justify the value of virtual time

    and Time Warp, we argue later that (1) distributed rollback has a natural and elegant implementation; (2) whenever rollback occurs, other rollback-free implementations would require blocking for an amount of real time equal to that spent on wasted computation; and (3) that rollback will usually occur relatively infrequently.” 4
  4. Overview • When a conflict is discovered after the conflict,

    the offending processes are rolled back to the time just before the conflict and then executed forward again. • Detection of conflicts and rollbacks are transparent to users. 5
  5. Virtual Time Definition • Virtual time is a global, one

    dimensional, temporal coordinate system on a distributed computation to measure computational progress and to define synchronization. • Virtual Times are real values(with +inf) and totally ordered by the relation <. • Virtual time is implemented a collection of several loosely synchronized local virtual clocks. 6
  6. Virtual Time Definition • Processes communicate with each other by

    exchanging message. • A Message has four values: – Name of the sender – Virtual send time – Name of the receiver – Virtual receive time • Virtual receive time is the virtual time when the message must be received. 7
  7. Virtual Time Definition • Virtual time systems follow below two

    rules • Rule 1. The virtual send time of each message must be less than its virtual receive time. • Rule 2. The virtual time of each event in a process must be less than the virtual time of the next event at that process. • These rules are exactly Lamport’s Clock Conditions. 8
  8. Virtual Time Definition • Causality of events is an important

    concept in distributed systems and is also a major constraint in the implementation of virtual time. • It is important an event that causes another should be completely executed before the caused event can be processed. • The constraint in the implementation of virtual time can be stated as follows:“If an event A causes event B, then the execution of A and B must be scheduled in real time so that A is completed before B starts”. 9
  9. Virtual Time Definition • Even though event A has an

    earlier virtual time than event B, we need not execute A before B if there is no causal chain from A to B. • Better performance can be achieved by scheduling A concurrently with B or scheduling A after B. • If A and B have exactly the same virtual time coordinate, then there is no restriction on the order of their scheduling. • If A and B are distinct events, they will have different virtual space coordinates (since they occur at different processes) and neither will be a cause for the other. • To sum it up, events with virtual time<t complete before the starting of events at time t and events with virtual time>t will start only after events at time t are complete from our viewpoint. 10
  10. Time Warp • Timestamp of a message is the virtual

    receive time. • The necessary and sufficient that a each process messages are handled in timestamp order. • It natural for some processes to get ahead in virtual time of other processes. 12
  11. Time Warp • It is impossible for a process on

    the basis of local information alone to block and wait for the message with the next timestamp. • It is always possible that a message with earlier timestamp arrives later. • So, when a process executes a message, it is very difficult for it determine whether a message with an earlier timestamp will arrive later. • This is the central problem in virtual time that is solved by the Time Warp mechanism. • Assumes that message communication is reliable, and messages may not be delivered in FIFO order. 13
  12. Time Warp • Time Warp mechanism consists of two major

    parts: local control mechanism and global control mechanism. • The local control mechanism in sures that events are executed and messages are processed in the correct order. • The global control mechanism takes care of global issues such as global progress, termination detection, I/O error handling, flow control, etc. 14
  13. The Local Control Mechanism • There is no global virtual

    clock variable; instead, each process has a local virtual clock variable. • The local virtual clock of a process does not change during an event at the process; it changes only between events. • The local virtual clock is changed to the timestamp of the next message. • At any time some local virtual clocks will be ahead of others. 15
  14. The Local Control Mechanism • When a message is sent,

    its virtual send time is copied from the sender’s virtual clock. But the name of the receiver and virtual receive time are assigned based on application specific context. • All arriving messages at a process are pushed in an input priority queue ordering timestamps. • Processes will receive late messages due to factors such as different computation rates of processes and network delays. • The semantics of virtual time needs that incoming messages be received by each process certainly in the timestamp order. 16
  15. The Local Control Mechanism • When the reception of a

    late message, the receiver rolls back to an earlier virtual time, cancels all intermediate side effects and then executes forward again. • If all the messages in the input queue of a process are processed, the state of the process is said to terminate and its clock is set to +inf. • However, the process is not destroyed as a late message may arrive resulting it to rollback and execute again. • Thus, each process is doing a constant “lookahead”, processing future messages from its input queue. 17
  16. The Local Control Mechanism • While a long computation, each

    process may roll back several times while progressing forward with rollback completely transparent to other processes in the system. • Rollback in a distributed system is complicated: A process that wants to rollback might have sent many messages to other processes, which in turn might have sent many messages to other processes, and so on, leading to deep side effects. • For rollback, messages must be effectively “unsent” and their side effects should be undone. This is achieved efficiently by using antimessages. 18
  17. Antimessages and Rollback Process is composed of the following •

    Process name: unique name in the system • Local Virtual Clock • State: data space of the process • State queue: It are needed in case of a rollback. • Input queue: Contains all recently arrived messages. • Output queue: Contains negative copies of send message. For every message, there exists an antimessage that is the same in content but opposite in sign. 19
  18. Antimessages and Rollback • When a process sends a message,

    a copy of the message is transmitted to receiver’s input queue and a antimessage is pushed in the sender’s output queue for sender rollback. • When a message and its antimessages appear in the same queue no matter in which order they arrived, a process remove two message from the queue. • When a message arrives at the input queue of a process with timestamp greater than virtual clock time of its receiver process it is enqueued. • When the receiver process’s virtual time is greater than the timestamp of received message, the process must do a rollback. 20
  19. Antimessages and Rollback In 2nd case: Name of Process: A,

    LVT: 180 160 165 170 178 183 184 Sending time 162 169 175 180 185 186 Receiving time E C D F B C Sender A A A A A A Receiver + + + + + + Sign … Input Queue 21
  20. Antimessages and Rollback In 2nd case: Name of Process: A,

    LVT: 180 160 165 170 178 183 184 183 Sending time 162 169 175 180 185 186 185 Receiving time E C D F B C B Sender A A A A A A A Receiver + + + + + + - Sign … Input Queue 22
  21. Antimessages and Rollback In 2nd case: Name of Process: A,

    LVT: 180 160 165 170 178 184 Sending time 162 169 175 180 186 Receiving time E C D F C Sender A A A A A Receiver + + + + + Sign … Input Queue Remove messages!! 23
  22. Antimessages and Rollback • When a process sends a message,

    a copy of the message is transmitted to receiver’s input queue and a antimessage is pushed in the sender’s output queue for sender rollback. • When a message and its antimessages appear in the same queue no matter in which order they arrived, a process remove two message from the input queue. • When a message arrives at the input queue of a process with timestamp greater than virtual clock time of its receiver process it is enqueued. • When the receiver process’s virtual time is greater than the timestamp of received message, the process must do a rollback. 24
  23. Antimessages and Rollback In 3rd case: Name of Process: A,

    LVT: 180 160 165 170 178 183 184 Sending time 162 169 175 180 185 186 Receiving time E C D F B C Sender A A A A A A Receiver + + + + + + Sign … Input Queue 25
  24. Antimessages and Rollback In 3rd case: Name of Process: A,

    LVT: 180 160 165 170 178 183 184 189 Sending time 162 169 175 180 185 186 190 Receiving time E C D F B C B Sender A A A A A A A Receiver + + + + + + + Sign … Input Queue 26
  25. Antimessages and Rollback • When a process sends a message,

    a copy of the message is transmitted to receiver’s input queue and a antimessage is pushed in the sender’s output queue for sender rollback. • When a message and its antimessages appear in the same queue no matter in which order they arrived, a process remove two message from the input queue. • When a message arrives at the input queue of a process with timestamp greater than virtual clock time of its receiver process it is enqueued. • When the receiver process’s virtual time is greater than the timestamp of received message, the process must do a rollback. 27
  26. Antimessages and Rollback In 4th case: Name of Process: A,

    LVT: 180 160 165 170 178 183 184 Sending time 162 169 175 180 185 186 Receiving time E C D F B C Sender A A A A A A Receiver + + + + + + Sign … Input Queue 28
  27. Antimessages and Rollback In 4th case: Name of Process: A,

    LVT: 180 160 165 170 178 183 184 164 Sending time 162 169 175 180 185 186 168 Receiving time E C D F B C B Sender A A A A A A A Receiver + + + + + + + Sign … Input Queue Conflict!! Occurs Rollback!! 29
  28. Rollback mechanism • Search the state queue for the last

    state with timestamp that is less than the timestamp of the received message and restore it. • Update the local virtual clock to timestamp of the received message and remove from the state queue all states after this time. Then the resume execution forward from this point. • Now all the messages that are sent between the current state and earlier state must be “unsent”, This is take care of by executing a simple rule: “To unsend a message, simply transmit its antimessage”. • This results in antimessage following the positive ones to the destination. A negative message causes a rollback according to the next page rules. 30
  29. Antimessage The antimessage protocol has several advantage: • It is

    extremely robust and works under all possible circumstances. • It is free from deadlocks as there is no blocking. • It is also free from deep side effects. • In the worse case, all process in system roll back to same virtual time as original one did and then proceed forward again. 31
  30. Antimessages mechanism There are some behavior at the receiver depending

    on the timing. • The original message has arrived but not yet been processed at the receiver. → The antimessage causes no rollback, however, it remove the original message from the receiver’s input queue and no record of that message. • The original message has already been partially or completely processed by the receiver. → The negative message causes the receiver to rollback to a virtual time when the original message was received. Receiver remove original message and no record of the negative message, then receiver rolls back. 32
  31. Antimessages mechanism • A antimessage can also arrive at the

    receiver before the original one. → It is pushed and will be remove when original message arrives. • If it is antimessage’s turn to be executed at a process’s input queue, the receiver take a no-op. When the corresponding original message arrives, It will remove antimessage and no record the original message. 33
  32. Demonstration of Time Warp Name of Process: A, LVT: 180

    160 165 170 178 183 184 Sending time 162 169 175 180 185 186 Receiving time E C D F B C Sender A A A A A A Receiver + + + + + + Sign … Input Queue 162 169 175 Sending time 164 171 179 Receiving time A A D Sender B E A Receiver - - - Sign … Output Queue 147 150 162 169 175 LVT of State 8 9 5 10 135 Saved State State Queue … 36
  33. Demonstration of Time Warp Name of Process: A, LVT: 180

    160 165 170 178 183 184 164 Sending time 162 169 175 180 185 186 166 Receiving time E C D F B C B Sender A A A A A A A Receiver + + + + + + + Sign … Input Queue 162 169 175 Sending time 164 171 179 Receiving time A A D Sender B E A Receiver - - - Sign … Output Queue 147 150 162 169 175 LVT of State 8 9 5 10 135 Saved State State Queue … Need Rollback!! 37
  34. Demonstration of Time Warp Name of Process: A, LVT: 166

    160 164 165 170 178 183 184 Sending time 162 166 169 175 180 185 186 Receiving time E B C D F B C Sender A A A A A A A Receiver + + + + + + + Sign … Input Queue 162 Sending time 164 Receiving time A Sender B Receiver - Sign … Output Queue 147 150 162 LVT of State 8 9 5 Saved State State Queue … Rollback and Send Antimessages!! 38
  35. Global Control Mechanism Global virtual time(GVT) is defined by the

    minimum value of all virtual clocks. • All processes can destroy all messages and all state older than GVT for memory management. • When GVT reaches +inf, this computation was finished. 39
  36. Examples Used • Distributed Discrete Event Simulation • Distributed Database

    Concurrency Control • Virtual Circuit Communication 40
  37. Comments • It seem that to determine virtual receive time

    is difficult for programmer. • How much do we need memory space for state queue? In some usage, It seems that we need huge memory more than synchronization mechanism based on block and resume. 41
  38. 42