Skip to content

Conversation

@heyihong
Copy link

@heyihong heyihong commented Jan 1, 2026

This lock-free implementation leverages atomic operations to avoid locking and context switching. Besides, it uses the sequence number exclusively, rather than relying on nanosecond-level information. Based on microbenchmarks, it can generate more UUIDv7 values within a given period of time.

Before:

go test -bench=BenchmarkUUID_NewV7 -benchtime=10s -run=NONE

goos: darwin
goarch: arm64
pkg: github.com/google/uuid
BenchmarkUUID_NewV7-8         	17931745	       664.1 ns/op
BenchmarkUUID_NewV7Pooled-8   	66918664	       180.4 ns/op

After:

go test -bench=BenchmarkUUID_NewV7 -benchtime=10s -run=NONE

goos: darwin
goarch: arm64
pkg: github.com/google/uuid
BenchmarkUUID_NewV7-8         	18219297	       655.6 ns/op
BenchmarkUUID_NewV7Pooled-8   	71690725	       167.7 ns/op

@heyihong heyihong requested a review from a team as a code owner January 1, 2026 17:24
@google-cla
Copy link

google-cla bot commented Jan 1, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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

Successfully merging this pull request may close these issues.

1 participant