Make_ref/0 non-unique before 2^82 calls?

I am a new arrival to learning and programming Elixir. I was curious about the claim in the book Programming Elixir that:

The function make_ref creates a globally unique reference; no other reference will be equal to it. We don’t use references in this book.

So I tried it across two instances of iex and in way fewer than 2^82 calls I was able to produce a collision. So, I looked around a bit online and found this was a “known issue” and that it was unique enough. The official docs at described the repeat happening after 2^82 calls. Since I did this manually in two REPL instances, I didn’t get anywhere near that number of calls. Is this expected and should I file an issue against the documentation?



If I had to guess, the uniqueness guarantees are only about repeated values in a given node. Not entirely sure how that’s handled in a multinode cluster, possibly each ref is tagged with some node identifier so that you don’t get collisions within a given node.

I would re-try your experiment but have the two nodes connected. I would also suggest having some way to send the ref across to the other node and check for equality directly, as I’m not sure you could rely on the IO.inspect output for that alone.

1 Like

It’s unique in a given cluster. Were your iex instances connected?

It does sound like the Elixir doc is a bit vague compared to the Erlang one:

1 Like