4 ms·
If you want to see what a rabbit hole looks like, parse this sentence from the article : "The beauty of this is that with a precise enough timer, you also solv
by ChuckMcM 12y ago
If you want to see what a rabbit hole looks like, parse this sentence from the article :
"The beauty of this is that with a precise enough timer, you also solve the multithreading issue because nothing ever happens at exactly the same time."
In the first part the author expresses a technique which narrows the window for failure, and adds a fallacy which sounds good but isn't true.
This way of thinking (narrowing windows to the point where they are probabilistically rare "enough") has been the source of many bugs.
Urs Hoezle (VP at Google) once said something I really liked which was "At a large enough scale, statistically impossible things happen every day." It is painful to accept but I've seen it in action.
- IvyMike 12y agoAnother quote echoing the exact same sentiment: "One in a million is next Tuesday" http://blogs.msdn.com/b/larryosterman/archive/2004/03/30/104165.aspx http://blogs.msdn.com/b/larryosterman/archive/2004/03/30/104...
- xsmasher 12y agoHe'd be better off getting the time in seconds, and then choosing a random number as well. At least then the chance of collision would be a known probability!
- ivanca 12y agoYou can have a different constant in every server, for example nanoseconds in server A will always be 0001, in computer B it will always be 0002 and so on. It's cheap computationally and there can't be no collision.
- codexon 12y agoI had the same feeling when people suggested using completely random UUIDs for things like cookies and transactions.
- X-Istence 12y agoThis just comes down to probability. It is extremely improbable to the point that the heat death of the universe would probably happen first, yet it is something that can worry...
- shin_lao 12y agoYou're most likely to have a bug caused by a hardware failure than a problem caused by colliding UUIDs (provided they are properly generated or large enough).
- shin_lao 12y agoThanks for the feedback, but did you notice this part? In our case, we have some additional homework to make it work on several nodes that is well beyond the scope of this post As for multithreading, the functions are guaranteed monotonic. "nothing happens at the same time" is a reference to the laws of physics.