Closed LiosK closed 2 years ago
For reference: simple stateless UUIDv7 implementation that utilizes 16-bit (~15 usec) precision sub-second fraction in C
@LiosK, with the current state of Draft 03 and UUIDv7 does this still have any place in the document?
Nope. This issue should be closed together with the 03 PR.
I added a comment re extra precision, and this issue might be relevant to the extra timestamp precision component.
Thanks @LiosK,
This could be re-used as a sample use-case for UUIDv8. That way I have some code to display at least one way to utilize UUIDv8 for an exotic timestamps somebody cooks up.
One of the benefits of the sub-second fraction representation is that we no longer need to stick to decimal clock resolutions like msec, usec, and nsec. We can employ some exotic precision resolutions such as ~0.25 milliseconds (1 / 4096 seconds) and ~5 microseconds. Please take a look at the following quick C code that prints the leading 48 bits of a UUIDv7:
The above code truncates microsecond-precision (in my environment) sub-seconds to ~0.25-millisecond precision in order to fully utilize the 12-bit subsec_a space. With the sub-second fraction representation, truncating a decimal timestamp to a convenient size is always a good option to pack the timestamp into a binary field efficiently.
I think the RFC should include this approach in one way or another because, though some implementers might invent similar techniques, many might naively implement the microsecond-precision example layout as in the draft 02 and just waste ~4 bits. Also, this approach might help resolve the endless debate over the length of sub-second fields like #24.