-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
optimize: changed xid generation strategy to snowflake #2412
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2412 +/- ##
==========================================
Coverage 50.93% 50.93%
Complexity 2813 2813
==========================================
Files 557 557
Lines 17823 17823
Branches 2076 2076
==========================================
Hits 9079 9079
Misses 7858 7858
Partials 886 886 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And Now. IdWorker would expired at
2088-09-06 15:47:35
If change the twepoch to 2020, IdWorker would expired at about 2093.
I think give 41 bit for time is a little bit long. 5-10 year maybe enough, because we can change the twepoch at 5-10 years later.
ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if (lastTimestamp == timestamp) { | ||
sequence = (sequence + 1) & sequenceMask; | ||
if (sequence == 0) { | ||
timestamp = tilNextMillis(lastTimestamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need some output shows that the sequence is not enough to use?
} | ||
lastTimestamp = timestamp; | ||
} | ||
return ((timestamp - twepoch) << timestampLeftShift) | (workerId << workerIdShift) | sequence; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you ensure order when timestamp-twepoch is greater than 2^22?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2^42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@long187 will this pr have any effect on the field length of saga |
Ⅰ. Describe what this PR did
optimize xid generation strategy
Ⅱ. Does this pull request fix one issue?
#2416
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews