Skip to content

Conversation

@mbrandenburger
Copy link
Member

@mbrandenburger mbrandenburger commented Nov 28, 2025

  • switch to github.com/google/uuid for uuids
  • more allocation friendly uuid string function
  • uuid benchmarks
  • remove GenerateUUIDOnlyLetters

@mbrandenburger mbrandenburger self-assigned this Nov 28, 2025
@mbrandenburger mbrandenburger added the enhancement New feature or request label Nov 28, 2025
@mbrandenburger mbrandenburger added this to the 25Q4 milestone Nov 28, 2025
@mbrandenburger mbrandenburger marked this pull request as ready for review November 28, 2025 19:18
Comment on lines 53 to 63
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()
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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>
Copy link
Contributor

@SaidAltury-ibm SaidAltury-ibm left a 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!

@mbrandenburger mbrandenburger merged commit 022fab2 into hyperledger-labs:main Dec 2, 2025
22 of 23 checks passed
@mbrandenburger mbrandenburger deleted the uuid branch December 2, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants