Implementation of Lamports Scalar clocks and SinghalKshemkalyanis VC

  • Slides: 18
Download presentation
Implementation of Lamport's Scalar clocks and Singhal-Kshemkalyani’s VC Algorithms Kent State University Computer Science

Implementation of Lamport's Scalar clocks and Singhal-Kshemkalyani’s VC Algorithms Kent State University Computer Science Department Saleh Alnaeli Advanced Operating System. Spring 2010

Goals Implementing both of the algorithms n study their behavior under some different arguments

Goals Implementing both of the algorithms n study their behavior under some different arguments n ¨ Processes Number ¨ Messages Number ¨ Involved processes Number in the computation Note: This presentation assumes that you have a back ground about Logical Clocks and some of its related algorithms (Scalar, Vector, S-K).

Lamport's Scalar clocks n n n was proposed by Lamport 1978 to totally order

Lamport's Scalar clocks n n n was proposed by Lamport 1978 to totally order events in distributed system each process Pi has a logical clock Ci (represented as integer value) n consistency condition ¨ consistency: if a b, then C(a) C(b) n ¨ strong consistency: consistency and n n if event a happens before event b, then the clock value (timestamp) of a should be less than the clock value of b if C(a) C(b) then a b scalar clocks are not strongly consistent: if a b, then C(a) C(b) but ¨ C(a) C(b), then not necessarily a b ¨

Implementation of Scalar Clocks n n n Rule 1: before executing event update Ci

Implementation of Scalar Clocks n n n Rule 1: before executing event update Ci so, Ci : = Ci + d (d>0) Rule 2: attach timestamp of the send event to the transmitted message when received, timestamp of receive event is computed as follows: Ci : = max(Ci , Cmsg) and then execute R 1 It is implemented in C++ and was verified in different ways: ¨ Checking its consistency using a function compares the new value of previous one locally and with the sender in receive event ¨ Results were compared with vector clock application

Generating the computations Computations were entered from input text file n Generated manually and

Generating the computations Computations were entered from input text file n Generated manually and using a computation generator developed in C++ randomly (random sender and receiver) n Each event is constructed according the following scheme: Event. Type, Sender. ID, Receiver. ID such that: n Event. Type is 1 for internal event, 2 for send event and 3 for receive event. ¨ Example: 3, 7, 8 means an event to receive a SMS was sent by Pcocess 7 to 8 // Also ¨ order of the events can be changed in the Input. File just make sure the receive event is preceeded by send event ¨ SMS not found or lost for receive without send event. ¨ Sending to process it self is an internal event. Example 2, 5, 5

Singhal-Kshemkalyani’s Algorithm for vector clock S-K n n n Considered as an efficient implementation

Singhal-Kshemkalyani’s Algorithm for vector clock S-K n n n Considered as an efficient implementation of vector clocks. instead of sending the whole vector only need to send elements that changed. And same update rules are used for the recipient process. maintain two vectors : n n LS[1. . n] – “last sent” LU[1. . n] needs to send with the message only the elements that meet the condition: {(x, vti[x])| LSi[j] < LUi[x]} The sent vector contains the processes’ Id’s and Clock values of changed processes.

S-K Implementation n It is implemented in C++ and was verified in different ways:

S-K Implementation n It is implemented in C++ and was verified in different ways: ¨ Results were compared with others generated by a combined Scalar and vector clock application. ¨ Known examples and random computations were used. n Computations were entered from input text file Computations were generated using a computation generator developed in C++. n

Events construction scheme n similar to scalar events format with extra field: n Event.

Events construction scheme n similar to scalar events format with extra field: n Event. Type, Sender. ID, Receiver. ID, Event. Id such that: Event. Type is 1 for internal event, 2 for send event and 3 for receive event. Event. Id is number of the event when the message has been sent ¨ Example: 3, 7, 8, 4 means an event to receive a SMS was sent by Process 7 to 8 and the event was the fourth send event ¨ order of the events can be changed in the Input. File just make sure the receive event is preceeded by send event ¨ SMS not found or lost for receive without send event. ¨ Sending to process it self is an internal event. Example 2, 5, 5, 4

Performance Evaluation n Lamport’s Scalar Clock algorithm: ¨ There n were not enough area

Performance Evaluation n Lamport’s Scalar Clock algorithm: ¨ There n were not enough area to study (trivial) S-K algorithms ¨ Performance n Stamps Memory size used in units (1 unit=32 bytes) ¨ Conditions n ¨ It’s metrics evaluated include of varying Processes Number, messages Number, and number of the involved processes in the computation. expected that SK in the worst case will perform as VC

S-K: Simulation Parameters Parameter Default Values Processes numbers 50 -100 // constant 50 Simulation

S-K: Simulation Parameters Parameter Default Values Processes numbers 50 -100 // constant 50 Simulation Cycles 15 Messages Number 500 -2500 Involved processes in computation 100%-50% // 100%-20% (10 -50 of 50) Events sequence 1 All Send to all and all receive (50 lost) Event sequence 2 Randomly send and direct receive Expectations: In the worst case of S-K will be Vector clock’s work.

# processes vs. #messages n n events by sequence 1 with 2500 messages and

# processes vs. #messages n n events by sequence 1 with 2500 messages and 50 lost figure 1 shows that S-K out performance regular VC even with changing the No of processes and involved processes as well Not Sufficient and not satisfied

#Messages vs. #involved processes Events were generated randomly with sequence 2 (randomly picking sender

#Messages vs. #involved processes Events were generated randomly with sequence 2 (randomly picking sender and receiver) n After sending, message is directly received to got more updates in locals V. n Constant # of processes 50 n Changing # of involved processes (10 -50) n

Figure 2 shows surprising results

Figure 2 shows surprising results

 table 1 500 Messages Number 1000 1500 10 5318 10804 15264 21152 27020

table 1 500 Messages Number 1000 1500 10 5318 10804 15264 21152 27020 20 12412 25966 39054 54974 66504 30 17026 40906 64556 85070 110548 40 22698 56564 88224 119018 152488 50 24202 65326 105732 153888 189428 Table 2 500 1000 1500 2000 2500 10 250000 75000 100000 125000 20 250000 75000 100000 125000 30 250000 75000 100000 125000 40 250000 75000 100000 125000 50000 75000 100000 125000 2500 Used memory in units # involved processes Table 1 and table 2 S-K and VC respectively

Verifying S-K efficiency equation n S-K original paper states that their technique can be

Verifying S-K efficiency equation n S-K original paper states that their technique can be beneficial if n<N. b/(log 2 N+b) Such that: n=avr of entries in Ti, b=bits in a sequence number, log 2 N=bits needed to code N process ids. n It doesn’t work with my simulation !!! ¨I have calculated n value in (2500, 40 and 110548, 30 ) and I compared it with their equation but did not work!!! n Mine is : ¨ When of involved processes gets close to 70% and #of messages gets close to 20 N, then S-K becomes inefficient.

Conclusion n n . The sequence of the events plays big role in determining

Conclusion n n . The sequence of the events plays big role in determining the efficiency of S-K Number of the involved processes in the computation can affect S-K performance For low # of messages, S-K seems fine. When # of involved processes is about 70% and #of messages close to 20 N then S-K becomes a weak. Efficiency equation is not applicable in my experiment

Difficulties The most difficult issue was generating a computation that can be used for

Difficulties The most difficult issue was generating a computation that can be used for adequate results. n It’s Difficult to predict the order of receiving the messages which make it difficult to generate a computation close to reality. n

References Original S-K paper n Logical clock, Adv OS course slides. n ¨ Prof.

References Original S-K paper n Logical clock, Adv OS course slides. n ¨ Prof. Mikhail Nesterenko (Acknowledge) ¨ http: //deneb. cs. kent. edu/~mikhail/classes/aos. s 10/ n S-k implementation-Manas Hardas. KSU. (Acknowledge)