-
Notifications
You must be signed in to change notification settings - Fork 63
refactor: enhanced uuid #1095
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
refactor: enhanced uuid #1095
Conversation
pkg/utils/uuid.go
Outdated
| if poolPos == randPoolSize { | ||
| _, err := io.ReadFull(rand.Reader, pool[:]) | ||
| if err != nil { | ||
| poolMu.Unlock() | ||
| panic(fmt.Sprintf("Error generating UUID: %s", err)) | ||
| } | ||
| poolPos = 0 | ||
| } | ||
| copy(uuid[:], pool[poolPos:(poolPos+16)]) | ||
| poolPos += 16 | ||
| poolMu.Unlock() |
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.
does't that break RFC 4122 assumption (a Universally Unique IDentifier is unique across both space and time, with respect to the space of all UUIDs) and introduce correlation between consecutive UUIDs (each 16)? and the locking limits parallel UUID generation in high scale do we want that?
WYT?
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.
interesting thoughts! I've remove this impl an added github.com/google/uuid. I think there is no need to reinvent the wheel here.
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.
I did some benchmarking, and even though with the lock used here, it is still faster than doing a sys call for each operations.
- switch to github.com/google/uuid for uuids - more allocation friendly uuid string function - uuid benchmarks - remove GenerateUUIDOnlyLetters Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
SaidAltury-ibm
left a comment
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.
Looks Good, thank you!
Uh oh!
There was an error while loading. Please reload this page.