Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Uid] AddUuidV1::toV6(),UuidV1::toV7() andUuidV6::toV7()#53060

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 2 commits intosymfony:7.1fromfancyweb:uid/v6-v7-convert
Dec 26, 2023

Conversation

@fancyweb
Copy link
Contributor

@fancywebfancyweb commentedDec 13, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?false
Issues-
LicenseMIT

The goal is to help working with new UUIDv6 & v7 versions when you receive legacy UUIDv1.

UUIDv6 and v1 are 100% compatible since v6 is just a "reordering" of v1.

UUIDv7 and v1 are not strictly compatible for several reasons: the timestamp precision is not the same. Also, there is no clock seq or variant or node in v7 but full randomness instead. And maybe others?
However, I believe we can still technically do the conversion (timestamp -> timestamp, clock seq + variant + node -> randomness) with at least one concession: the sub-milliseconds v1 timestamp precision is lost since v7 doesn't support it.

My proposed v1 to v7 implementation has 2 issues:

  • sub-microsecond entropy is entirely lost
  • monotonicity is lost?

I'm opening this PR so that@nicolas-grekas gets triggered by the inefficiency of my code and finds a better solution 😁
I'm kidding, I actually know he already has an idea because he explained it to me during the Brussels HackDay but I couldn't understand it well enough to be able to implement it 😅

OskarStark reacted with thumbs up emojiNyholm reacted with laugh emoji
@nicolas-grekasnicolas-grekas changed the title[Uid] AddUuidV6::fromV1() andUuidV7::fromV1() methods[Uid] AddUuidV1::toV6(),UuidV1::toV7() andUuidV6::toV7()Dec 19, 2023
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for pushing this :)

I added a second commit where I renamedfrom*() methods toto*()
and I made the resulting UUIDv7 monotonic within the same 100-ns (modulo the clock-seq)

fancyweb reacted with rocket emoji
Copy link
ContributorAuthor

@fancywebfancyweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you very much for looking at this Nicolas 🐐

It looks like we are close to the perfect solution thanks to you. However, after reviewing it and testing it I've found that the xor doesn't always produce valid UUIDs (see failing test).

Also, what do you think of going directly from v1 to v7 to avoid the unneeded v6 step? I'm actually not even sure v6 -> v7 is needed at all since they are part of the same RFC iteration: I don't see any case where a system would be able to generate v6 but not v7 directly? 🤔

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedDec 21, 2023
edited
Loading

Also, what do you think of going directly from v1 to v7 to avoid the unneeded v6 step? I'm actually not even sure v6 -> v7 is needed at all since they are part of the same RFC iteration: I don't see any case where a system would be able to generate v6 but not v7 directly? 🤔

It doesn't cost much to provide v6 to v7 so why skip it?

@fancyweb
Copy link
ContributorAuthor

I don't cost much to provide v6 to v7 so why skip it?

Because nobody will use it 😅

I reviewed it again and it's OK for me. I can't approve it since it's my own PR. I force-pushed again to add more assertions.

@nicolas-grekas
Copy link
Member

Thank you@fancyweb.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

5 participants

@fancyweb@nicolas-grekas@stof@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp