> On Jun 22, 2016, at 06:27, Bruno Bonacci <bruno.bona...@gmail.com> wrote: > > @Brian, The clock drift problem was in answer to your question and generally > it was referring to the pure System/currentTimeMillis implementation. The > System/nanoTime, as it is now, is completely broken as it offsets against the > wall clock and not the previous System/nanotime, but that it is easy to fix.
Note that the current implementation mirrors Skuld’s. When calculating a timestamp we provide an epoch, derived at startup. The epoch is constructed by taking a sampling of the difference between System/currentTimeMillis and System/nanoTime and averaging the results: this is meant to detect jitter. We don’t use the wall clock at any point after that for constructing flakes. Because timestamps are persisted to disk, the next time we run our generator, we ensure that the epoch used is always larger than the last timestamp written. (We could also use the epoch to derive a timestamp and ensure the derived timestamp is larger, which might be better thinking about it now.) This protects against clock skew between runs. To address your question about clock skew during runs, it’s true that System/nanoTime is not necessarily monotonic. However the process of generating a new flake always rejects timestamps that appear in the past relative to the last flake. So a monotonic property is built into our program. As you note, this could result in thrashing if the delta is extreme or System/nanoTime is somehow always returning smaller values—but I don’t know of a better way of addressing that issue currently. I think the salient point here though is that we do enforce a monotonic property at the application level which should protect us against duplicate IDs. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.