Pergunta

I've heard about vector clocks and how to test if a message was sent before another message.

E.g. Message A was sent before message B if every element of the vector of message A is smaller or equal then the belonging element of the vector of message B.

Also, there needs to be at least one element in the vector of message A that is smaller (and not equal) than the belonging element of message B.

As I see, the second parts just tests if there are elements that differ.

Is there a possibility where all elements of the vector of message A are the same as the belonging element of the vector of message B or is the second check unnecessary?

I mean, each element can only be incremented by the belonging process only and there if e.g. process X sends a message to process Y and a message gets back, the element of process Y will be changed in process Y only and the element of process X will be changed in process X only. So, there would be an update from the own element and the foreign element in any case. This means, there could not possibly be a case where all elements of the vector of message A and all elements of the vector of message B are completely the same, right?

Could the performance of the vector clock be increased if the test for equality is removed?

Foi útil?

Solução

Given that the algorithm for vector clocks is defined such that any process increases one of the values in the vector it should be impossible for any two distinct VC to have the same value.

However, there is obviously the trival case of comparing a message with itself, when you would of course expect the VC to be equal as they are duplicates of each other.

Less trivially, although the algorithmic definition should never produce a duplicate value, it's easy to see that in practice each line of code in a process might not update the VC, if you use the VC out side of the processes, perhaps for logging, or your messages run on an underlying transport mechanism such as a queuing software which doesn't implement the VC itself; that you could end up with the same VC being used in more than one place.

Skipping the equality step doesn't seem advisable

Licenciado em: CC-BY-SA com atribuição
scroll top