News for hackers. Stuff that matters.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by garmaine on Saturday November 20, 2021 @12:01AM (#29285701)
> It’s a 64bit random number so it’ll never have unintentional collisions.

It'll have unintentional collisions if you ever generate more than 4 billion of these random numbers. That's not inconceivable.

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by NavinF on Saturday November 20, 2021 @12:30AM (#29285826)
Yes it is. Message schemas are made by humans. Most of these messages will be extended in a backwards compatible manner over the life of a project rather than replaced entirely so their IDs don’t change. That’s kinda the point of protobufs and its successors.

I’ve probably generated 100 IDs over my lifetime.

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by garmaine on Saturday November 20, 2021 @03:25AM (#29286482)
Which puts it on the same order of magnitude as the number of people on the planet. If every person alive generated a schema (or if 1/100th of all people generate 100 IDs each like you) then we'd have a small number of collisions. More likely you'd get large numbers of schema like that if there's a widespread application of a protocol compiler that generates new schema programmatically, e.g. to achieve domain separation, and then is applied at scale. I'm not saying that's likely, just that it is not, as is claimed, inconceivable.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by kentonv on Saturday November 20, 2021 @10:28AM (#29288901)
It's only really a problem if you use the IDs in the same system. It's highly unlikely that you'd link 4B schemas into a single binary. And anyway, if you do have a conflict, you'll get a linker error.

Cap'n Proto type IDs are not really intended to be used in any sort of global database where you look up types by ID. Luckily no one really wants to do that anyway. In practice you always have a more restricted set of schemas you're interested in for your particular project.

(Plus if you actually created a global database, then you'd find out if there were any collisions...)

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by heavenlyblue on Saturday November 20, 2021 @08:29AM (#29287878)
If you have 4 billion of them generated there’s another 1/4billionth chance you’ll generate a duplicate.

On top of that you would not only need to generate the same ID, you would need to USE it in the same system where that is could have some semantics to not cause an error.

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by logicchains on Saturday November 20, 2021 @01:02AM (#29285934)
>It'll have unintentional collisions if you ever generate more than 4 billion of these random numbers.

If it's 64 bit, doesn't that mean you'd need to generate ~10000000000000000000000000000000000000000000000000000000000000000 (2^64) of those numbers to have a collision, not 2^32?

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by tomerv on Saturday November 20, 2021 @01:12AM (#29285974)
If you generate randomly then, due to the birthday paradox, after generating sqrt(N) values you have a reasonable chance of collision.

The birthday paradox is named after the non-intuitive fact that with just 32 people in a room you have > 50% of 2 people having a birthday on the same day of the year.

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by doo_daa on Saturday November 20, 2021 @01:37AM (#29286062)
I think it's 23 people in a room. The canonical example is people on a football (soccer) pitch. With 11 per side plus the referee there's a 50% chance that two will share the same birthday.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by adwn on Saturday November 20, 2021 @01:31AM (#29286042)
> 32 people

Slight correction: only 23 people, actually. So in every second football ("soccer") game, you have two people on the field with the same birthday.

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by ratorx on Saturday November 20, 2021 @02:36AM (#29286291)
Does birthday paradox apply here? It’s about any pair of people having the same birthday, whereas in this case you need someone else with a specific birthday.

For example, if you generate 2 numbers and they are the same, but are different to the capnproto number, that’s a collision but doesn’t actually matter.

EDIT: It does apply, I misunderstood what the number was being used for.

Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by elcritch on Saturday November 20, 2021 @03:17AM (#29286454)
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by ratorx on Saturday November 20, 2021 @03:26AM (#29286489)
You’re right, I misunderstood what the magic number was being used for.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by lozenge on Saturday November 20, 2021 @04:07AM (#29286611)
But if my application only uses 100 schemas, I only care about a collision if it's with one of those 100.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by gpderetta on Saturday November 20, 2021 @06:50AM (#29287273)
You have a collision if any two schemas share the id, not if a specific schema collides with any of the others. So it is exactly like the birthday paradox.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by heavenlyblue on Saturday November 20, 2021 @08:34AM (#29287922)
Yeah, but that collision probably doesn’t matter because there’s a bunch of other variables that need to come together for it to be an issue at all.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by gpderetta on Saturday November 20, 2021 @09:50AM (#29288552)
If the schema id is the message id, in principle it could be an issue as the protocol on the wite would be ambiguous. Then again, you should be able to detect any collisions when you register a schema with the schema repo and deal with it at that time.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by heavenlyblue on Saturday November 20, 2021 @08:26AM (#29287858)
I don’t understand your maths here: how is generating 4billion of them is any different from generating 3 billion except a slight raise in the probability measure?
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by remram on Saturday November 20, 2021 @12:10AM (#29285745)
When you reach the 4 billionth version of your protocol?
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by kentonv on Saturday November 20, 2021 @10:30AM (#29288918)
All versions of the same protocol have the same ID. That is the point of IDs -- to link together different versions of the protocol.
Re:Amazon Ion – A richly-typed, self-describing, hierarchica... by remram on Saturday November 20, 2021 @05:19PM (#29292359)
You're right! That makes collisions even less likely then.