Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erlang:now issues when generating ids #4

Open
ghost opened this issue Mar 26, 2012 · 0 comments
Open

erlang:now issues when generating ids #4

ghost opened this issue Mar 26, 2012 · 0 comments
Assignees

Comments

@ghost
Copy link

ghost commented Mar 26, 2012

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.

@ghost ghost assigned d2fn Aug 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant