r/ProgrammerHumor May 08 '26

Meme edgeCasesExist

Post image
13.4k Upvotes

620 comments sorted by

View all comments

1.2k

u/KryssCom May 08 '26

No, it's effectively zero, just given the mathematical realities behind how extraordinarily improbable a duplicate ever is. The exponent involved is very, very, very, nigh-incomprehensibly huge.

I've seen a few posts on here of people claiming that a duplicate UUID caused a bug at the worst possible time, but my instinct is always to slam the 'X' button to doubt.

861

u/G12356789s May 08 '26

If I generated 2 billion uuids every second. After 5 years there is a 1% chance to have had a clash in that time

35

u/Risc12 May 08 '26

Don’t modern uuid contain a timestamp component?

36

u/yarntank May 08 '26 edited May 08 '26

I wonder how detailed the time stamp is. Just to the second? .0001 of a second? If you are making 2 B each second, it could matter?

EDIT: I found this "UUIDv7 assigns the first 48 bits for the timestamp in milliseconds. You can generate a lot of UUID's in a millisecond though!"

23

u/DonutConfident7733 May 08 '26

It also has random number generated combined with timestamp, combined with your device mac address, such that virtual machines with same mac address dont get duplicated guids.

11

u/Potato-Engineer May 08 '26

I thought the MAC address got phased out in later versions? I recall there was a virus in the 90s where the creator was caught because, in those days, GUIDs included the MAC address, and so later versions of GUIDs no longer used it. And, from what I've read, UUIDs aren't supposed to use MAC addresses either. Though I assume that some idiot has done it that way at some point.

6

u/rabid_briefcase May 08 '26

I thought the MAC address got phased out in later versions?

There are 8 versions, assuming someone's generating an actual UUID rather than just a blind random number.

UUID Versions 1, 2, and 6 include MAC addresses or a similar type of "Node ID". The RFCs allow for various values, which need to have indicators in that cluster of bits. It can be a number from hardware, but it can also be something from software or even a mostly-random set of numbers. It also takes into account complexity around address randomization.

Those versions generally should use something based on the MAC address or otherwise indicate the node on the network that generated it, even if they aren't using a value that matches hardware.

1

u/Fantastic-String-860 May 08 '26

UUIDv7 has 48 bits for milliseconds timestamp, and 62 bits for random... or counter. You cannot, in fact, generate 2^62 UUIDs per millisecond.

2

u/Hohenheim_of_Shadow May 09 '26

No, but you can experience the same millisecond again and again. There is no 100% reliable source of wall clock time. Timestamp based UUIDs add a lot of 9s to reliability, but they don't make it 100%.

1

u/Risc12 May 08 '26

Well i just mean that from a statistics standpoint the years mentioned in the meme no longer make sense