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] Add microsecond precision to UUIDv7 and optimize on x64#60898

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 1 commit intosymfony:7.4fromnicolas-grekas:uuidv7-us
Jun 27, 2025

Conversation

nicolas-grekas
Copy link
Member

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

This makes our implementation of UUIDv7 follow method 3 described by the RFC:
https://www.rfc-editor.org/rfc/rfc9562#section-6.2-5.6.1

UUIDv7 will now contain microsecond timestamp instead of just milliseconds.
This allows optimizing the code a bit, and I further optimized the x64 code path.
This makes the generation logic about 10% faster.

Copy link
Member

@alexandre-dauboisalexandre-daubois left a comment
edited
Loading

Choose a reason for hiding this comment

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

Works nicely! Could we have a test covering that UUIDv7 microseconds is actually stored on generation? Something like:

publicfunctiontestV7MicrosecondPrecision(){$testCases = ['1645557742.000001','1645557742.123456','1645557742.999999'    ];foreach ($testCasesas$timeStr) {$timestamp = \DateTimeImmutable::createFromFormat('U.u',$timeStr);$uuidStr = UuidV7::generate($timestamp);$uuid = UuidV7::fromString($uuidStr);$expected =$timestamp->format('U.u');$actual =$uuid->getDateTime()->format('U.u');$this->assertSame($expected,$actual);    }}

@nicolas-grekas
Copy link
MemberAuthor

Thanks for the proposal, PR updated with a test case inspired from yours.

@nicolas-grekasnicolas-grekas merged commitfa8b32e intosymfony:7.4Jun 27, 2025
3 of 11 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

@alexandre-dauboisalexandre-dauboisalexandre-daubois approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

4 participants
@nicolas-grekas@OskarStark@alexandre-daubois@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp