![rw-book-cover](https://www.exhypothesi.com/content/images/2022/11/3-1.png) --- > because of clock drifts and/or assumptions around network time delays, timestamps from conventional clocks are not always mutually comparable, and therefore events cannot be reliably ordered using timestamps from conventional clocks - [View Highlight](https://read.readwise.io/read/01h12h0zdwrfsb9fhp5qpp5247) --- > If multiple nodes in a distributed system can rely on a centralized logical clock, then most issues discussed in this article become irrelevant. - [View Highlight](https://read.readwise.io/read/01h12h2cva0r5j668g3817f3qy) --- > For a distributed logical clock to function, we expect each of the participating nodes to have its own clock that cooperates with clocks on other nodes in order to produce the next timestamp - [View Highlight](https://read.readwise.io/read/01h12h32cyjxmt0p57g80r5kbe) --- > because events may occur faster than the notification of such events between nodes, events may be unaware of some [past](https://www.exhypothesi.com/clocks-and-causality/?ref=refind#future-and-past) events. Events that occur without the knowledge of each other are called concurrent events. - [View Highlight](https://read.readwise.io/read/01h12h44g1mjd50qz2xhjgvsj4) --- > Each timestamp produced by a logical clock consists of two components: > 1. an id for the current event, and > 2. the ids of some or all events the node is aware of thus far (aka history). - [View Highlight](https://read.readwise.io/read/01h12h78460nc27r6n9ec7qx8n) --- > Richness in the timestamp therefore needs to be purchased with space or time complexity. And different designs make different choices in this area. However, a common compaction scheme used by different clock designs is to track history with the use of *numbers* for event ids. Under this compaction scheme, an event with timestamp [ 5 ] not only represents that the event id is the number 5, but that the node generating that event has knowledge of the existence of (some) event [ 4 ] (because there could be multiple [ 4 ] events) and possibly all events prior to and equal to [ 4 ], depending on the clock. - [View Highlight](https://read.readwise.io/read/01h12h8dy1yp2ts739pmzyq95h) --- > If the knowledge from event A is *used* to produce event B, then A *caused* B. If B merely happened before C, but event C *did not use* the knowledge from event B, then B and C are not causally related, just temporally so. - [View Highlight](https://read.readwise.io/read/01h12h9vbjax3ybjaqx6ycfmqp) --- > Most applications, for simplicity, use temporal relationship as a proxy for causality. - [View Highlight](https://read.readwise.io/read/01h12ha6kgafvjbpx9yhy2qhk6) --- > Timestamps produced by a Lamport clock take the least amount of space, O(1) in terms of the number of [nodes](https://www.exhypothesi.com/clocks-and-causality/#node) in the [system](https://www.exhypothesi.com/clocks-and-causality/#complexity), compared to other clock designs. A Lamport timestamp captures the event id and some history of events the node is aware of at the time the event is generated, all using a single unique number. When a node generated event id [ 5 ], the node claims to have knowledge of some event that is numbered [ 4 ] and no knowledge of any other event that is numbered [ 5 ] or above. - [View Highlight](https://read.readwise.io/read/01h12hdvpxv9m3gty4gzfey1t7) --- > Lamport timestamps do not capture which node generated the event. - [View Highlight](https://read.readwise.io/read/01h12he4h9zn5320x5dzrpgrmy) --- > A Lamport clock can be implemented as follows: > 1. Timestamps are sequential numbers associated with events. > 2. Each node maintains its own sequence starting with number 0. > 3. When an event is generated, the node increments its number by one and associates that number with the event. > 4. When a node learns an event from another node, the node ensures its number to the highest of its own number and the event number it learned from the other node. - [View Highlight](https://read.readwise.io/read/01h12hg93xneck8qyf64ghcwph) --- > Lamport timestamps can be used to arrange events in a historical (i.e., happened-before) order *after the fact*. - [View Highlight](https://read.readwise.io/read/01h12hh0evv03dmmkkc08n9ta1) ---