Represent causal history component by component
Use vector updates and componentwise comparison to distinguish ordered events from concurrency under an explicit participant model.
On this page
The question for today
What you’ll understand
- Apply componentwise merge followed by the receiving participant’s increment.
- Compare vectors using the product order instead of a scalar sum.
- Explain the participant-identity, metadata, and capture assumptions behind a concurrency claim.
A scalar logical clock deliberately forgets which participant contributed each step of an event's history. A vector retains separate components, allowing a stronger comparison when the event model and instrumentation are complete. The extra information is valuable for identifying concurrent updates, but it costs metadata and identity management. Learn the comparison as a partial order first; then ask what must be true of participants, message propagation, and restarts for the vector's history to deserve its interpretation.
Each component names a participant’s history
For a fixed set of d participants, assign one component to each participant and initialize all components to zero. Before a local or send event, increment the component belonging to that participant. The event and any outgoing message carry the resulting vector. A component therefore tracks knowledge of a participant's event count within this model, rather than seconds spent executing there. Vectors must use the same component identities when compared. Treating the third position as node C on one machine and a newly joined node D on another destroys the meaning even if both arrays have identical numeric types.
At a receive event, take the componentwise maximum of the local vector and the message vector, then increment the receiver's own component. The merge preserves everything known on either side; the increment records that the receive itself is a new local event after the send. Messages must actually carry the relevant metadata through every modeled communication path. An uninstrumented queue, an external database handoff, or a process restart that resets an existing identity can break the intended causal-history interpretation. Use an incarnation or another justified identity scheme rather than recycling a component while stale messages remain possible.
Compare all components, not their sum
Define one vector as no later than another when every component is less than or equal to its counterpart. Strict order additionally requires at least one strict inequality. Under the standard fully instrumented vector-clock model, this strict comparison characterizes happened-before for distinct event timestamps. If one component is larger while another is smaller, neither vector is below the other; their events are concurrent in the modeled execution. Summing components or sorting them lexicographically loses this information. A convenient list order is a presentation decision, not an equivalent causality test.
Consider vectors (3, 1, 0) and (2, 2, 0). The first contains more A history, while the second contains more B history, so neither dominates. A later event stamped (3, 2, 1) can contain both histories. That observation does not decide how an application should merge conflicting values. A causal relationship and a business-level conflict are different questions: concurrent increments may commute, whereas concurrent replacements may need an explicit resolution policy. Preserve enough provenance to distinguish the cases rather than assuming that a vector clock chooses the correct winning update for the product.
Budget metadata and state the scope of ignorance
A straightforward vector carries d counters per timestamp, so communication and storage grow with the participant set. Dynamic membership, compact representations, and safe retirement require more than trimming old array entries: a removed participant can still have delayed messages or updates whose history affects comparisons. Practical systems may attach versions to replicas, objects, or other scoped identities instead of every thread. Their comparison semantics depend on that choice. Document what the vector summarizes and which protocol establishes that discarded history can no longer arrive. Compression that forgets necessary distinctions changes the claimed concurrency information.
The vector lab supplies a geometric analogy for componentwise incomparability. For each separate view, Reset, re-set angle and magnitude, predict both projections, then inspect the still frame. Compare angle 30 degrees and magnitude 2 with angle 60 degrees and magnitude 2. One positive x projection decreases while the positive y projection increases, so neither pair dominates. These are real-valued projections of one vector, not integer event histories or a vector-clock implementation. The analogy helps explain the comparison rule; the numerical exercise supplies the actual discrete causal updates and participant identities that the diagram does not contain.
Work it through
Merge two histories before recording a receive
Use participants A, B, C in that order. A sends a message stamped(2, 0, 0). B’s prior vector is(0, 1, 0). B receives the message, then sends to C, whose prior vector is(0, 0, 1). Use increment-before-send and merge-then-increment-on-receive.
B merges(0, 1, 0) with(2, 0, 0), obtaining(2, 1, 0), then increments B’s component to stamp its receive(2, 2, 0).
B’s next send increments its own component again, carrying(2, 3, 0). That send contains the history learned from A.
C merges(0, 0, 1) with(2, 3, 0), obtaining(2, 3, 1), and increments C’s component to(2, 3, 2). A’s send vector is strictly below C’s receive vector, consistent with the specified message chain.
C receives timestamp(2, 3, 2). Its vector includes the communicated A and B histories together with its own new receive event.
The living notebook
Explore the model
Interactive lab · vectors
A larger component can accompany a smaller one
For each separate view: Reset, set both angle and magnitude, predict the x/y projections, then inspect. Compare angle 30°, magnitude 2 with angle 60°, magnitude 2. The pairs are approximately(1.732, 1) and(1, 1.732). This is a geometric illustration of product-order incomparability, not a vector-clock or message-history simulator.
- x component
- 1.393
- y component
- 0.975
- Magnitude
- 1.7
Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forNeither pair is componentwise below the other. Actual vector-clock components are participant-indexed integer counters and require correct metadata propagation.
Pause & reason
Check your understanding
Your turn
Try it yourself
Receiver B has completed two independent local events and has vector(0, 2, 0). It receives a message from C stamped(3, 0, 2), using participant order A, B, C. Compute its receive vector. Does removing the A component afterward automatically preserve every comparison?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Take maxima first, then increment B. Think about two histories that differed only in the removed component.
Compare with the solution
The merged vector is(3, 2, 2), and incrementing B yields(3, 3, 2). The scenario is reachable: C can receive A’s third event at its first event, then send this message at its second, while B’s two earlier events remain independent. Deleting a component can collapse formerly distinct or incomparable histories; safe retirement needs a protocol establishing that the omitted distinctions can no longer matter.
Keep the idea
Take it with you
- Vector clocks retain participant-specific causal history at a metadata cost.
- Componentwise comparison preserves distinctions that scalar sorting discards.
- Concurrency claims rely on complete propagation, stable identities, and the stated event model.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.