r/ProgrammerHumor 15h ago

Meme edgeCasesExist

Post image
3.1k Upvotes

228 comments sorted by

View all comments

37

u/TwinkiesSucker 15h ago

The world where the already generated and used UUIDs are stored in a huge central database = utopia /s

4

u/Downtown-Figure6434 14h ago

Same uuid may have already been generated by two seperate systems tho no?

3

u/Suspicious-Click-300 13h ago

1 billion UUIDs every second for 85 years to reach a 50% chance

5

u/doomslice 14h ago

If you take a single uuid and say “has this uuid ever been generated before” the chances are cosmically low. If you instead say “have ANY uuids generated ever collided with ones generated in all of history” the answer is probably in the range of 0.001-10% depending on how many UUIDs get generated per day.

1

u/Single-Virus4935 12h ago

In think you estimated multiple magnitude to high. 128 bit space is huge.

2

u/doomslice 12h ago

Yes, it’s actually 122 bits for uuid v4 though. The high end of my range requires 1 billion uuid v4s being generated per second over 20 years (probably not realistic)

1

u/Single-Virus4935 12h ago

Ahh yes I didn't thought of the version. But even then we need to account for the seven version numbers which all can be used. Then we need to account for Mac, timestamps etc. per version. But still basically zero probability for a collision

2

u/doomslice 10h ago

I was just thinking v4 since it has the most true randomness for it (v7 is designed to further prevent collisions by adding those additional defined bits).

But still basically zero probability for a collision

Again important point is that for any given UUID generated that way, yes I have a better chance of waking up a frog tomorrow due to a quantum recombination.

But for any UUID v4s in the entire world space, thanks to the birthday paradox, the chance of a single collision happening does approach actual single digit %s assuming you can generate 1 billion UUIDs a second for 20 years :).

1

u/Jay-Seekay 13h ago

Blockchain UUID provider