Skip to content

erlang:now issues when generating ids #4

@ghost

Description

Problem stems from the fact that "guaranteed that subsequent calls to this BIF returns continuously increasing values"; see also https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_time_sup.c#L849
Hence

  1. "Sequence counter" id field will never go higher than 1000, wasting precious 6 bits.
  2. Generating more than 10e6 ids per second in one erlang wm will cause skewness of "time" id field, possibly resulting in incorrect ordering of ids from different machines; incomparability margin of these ids could grow uncontrollably.

Solution
Simply replacing erlang:now with os:timestamp seems to be enough.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions