3 ms·
Global uniqueness is certainly not "confirmed". With a 128-bit key, you have at most 2^128 different values (and it's actually slightly less because I think the
by eridius 15y ago
Global uniqueness is certainly not "confirmed". With a 128-bit key, you have at most 2^128 different values (and it's actually slightly less because I think the different UUID schemes all reserve at least one digit). Sure, collisions are extremely unlikely, but they are also extremely unlikely with the simple 128-bit random number.
- saurik 15y agoActually, no: they are "confirmed". The collisions in this scheme are administratively controlled. Think about it this way: with careful planning, you can use a 24-bit number and have a reasonably large space of non-conflicting values. I wouldn't trust rand() for this, but if there was a single server allocating numbers in sequential order, this would be fine. While at 128-bits, rand() starts becoming reasonable, the UUID algorithm is designed to produce the "actually guaranteed to be globally unique" experience that the sequentially incrementing counter did. On an individual computer, this requires coordinating with a library (preferably OS-supported, such as on Windows) in order to obtain global locks, allowing identifiers to then be identified by a timestamp (to guarantee that you can reuse the hardware later; this requires your clock to be monotonically increasing on any given piece of hardware, which in practice means "make it accurate"; there is a sequence numbering mechanism for allowing clock rollbacks). Between computers, node identifiers are MAC addresses, which are unique by administrative fiat (blocks are allocated to companies, who are responsible for guaranteeing the uniqueness of their devices; if you feel like some of these providers are not abiding by this, you can simply not use their hardware for your networking infrastructure, which is a good idea anyway due to how Ethernet works). If you haven't skimmed the spec, I recommend you do at some point: http://www.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-uuids-guids-01.txt http://www.ics.uci.edu/~ejw/authoring/uuid-guid/draft-leach-... """This specification defines the format of UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits long, and if generated according to the one of the mechanisms in this document, is either guaranteed to be different from all other UUIDs/GUIDs generated until 3400 A.D. or extremely likely to be different (depending on the mechanism chosen). UUIDs were originally used in the Network Computing System (NCS) [1] and later in the Open Software Foundation's (OSF) Distributed Computing Environment [2]."""
- eru 15y agoWith all the locks and stuff, I guess there's a bigger chance you screw up a complicated scheme and get two identical ids, than if you just us a good quality source of random bits. At least if your key is long enough. (I don't know, if 128 bits is enough.)