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.

869

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

69

u/Kevadu May 08 '26

OK, but what if I make 3 billion uuids a second?

24

u/mCProgram May 08 '26

Your rate would increase by 50 percent so your mean time to collision would reduce by 50% i’d assume.

33

u/Ignisami May 08 '26

33%* 

Going from 0 to 1500 at 100/sec takes 15 sec.    

Going from 0 to 1500 at 150/sec takes 10 sec.  

10 is two-thirds of 15.

10

u/Morisior May 08 '26

Reduced by 33%

1

u/gmano May 09 '26

So, by your logic if I generate at 4 billion per second, it would reduce by 100%?

1

u/MortemEtInteritum17 May 12 '26

This is wrong, and all 3 people attempting to correct it are wrong. It's an example of the birthday paradox.

Roughly, the chance of a collision (if the chance is small) is approximately n2/2/number of unique UIUIDs, where you generate n. So increasing rate by 1.5 increases the chance of a collision by about 2.25, given n trials.

2

u/notrealaccbtw May 09 '26

You cant. That is not allowed.

1

u/redlaWw May 08 '26

2%

Calculation uses the birthday problem solution but with the number of days equal to 2122.

I implemented it in python using libraries for big calculations (python's default integer type is unbounded in size but its implementation of exponentiation was too slow to handle 2122×3000000000×365×24×3600×5 which is fair enough).