Giter VIP home page Giter VIP logo

uuid_dotnet's Introduction

.NET Core implementation of UUIDv6, 7 and 8

Draft prototypes for UUIDv6 and beyond. Timestamp-based and machine-sortable.

  • UUIDv6 - UUIDv6, aims to be the easiest to implement for applications which already implement UUIDv1.
    The UUIDv6 specification keeps the original Gregorian timestamp source but does not reorder the timestamp bits as per the process utilized by UUIDv1.
    UUIDv6 also requires that pseudo-random data MUST be used in place of the MAC address.
    The rest of the UUIDv1 format remains unchanged in UUIDv6
  • UUIDv7 - UUIDv7 introduces an entirely new time-based UUID bit layout utilizing a variable length timestamp sourced from the widely implemented and well known Unix Epoch timestamp source.
    The timestamp is broken into a 36-bit integer sections part, and is followed by a field of variable length which represents the
    sub-second timestamp portion, encoded so that each bit from most to least significant adds more precision
  • UUIDv8 - UUIDv8 introduces a relaxed time-based UUID format that caters to application implementations that cannot utilize UUIDv1, UUIDv6, or UUIDv7.
    UUIDv8 also future-proofs this specification by allowing time-based UUID formats from timestamp sources that are not yet be defined.
    The variable size timestamp offers lots of flexibility to create an implementation specific RFC compliant time- based UUID while retaining the properties that make UUID great.

Implementation status

RFC/Draft version implementation: 01
UUIDv6: Not implemented, planned
UUIDv7: Work in progres
UUIDv8: Not planned

Implementation details

UUIDv7

Layout and bit order:

bytes      	0               1               2               3
		    0                   1                   2                   3
		    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
		   |                            unixts                             |
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bytes      	4               5               6               7
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
		   |unixts |       subsec_a        |  ver  |       subsec_b        |
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bytes      	8               9               10              11
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
		   |var|                   subsec_seq_node                         |
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bytes      	12              13              14              15
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
		   |                       subsec_seq_node                         |
		   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Benchmarks

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000
AMD Ryzen 7 5800X, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.400
  [Host]   : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT  [AttachedDebugger]
  .NET 5.0 : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT

Job=.NET 5.0  Runtime=.NET 5.0  
Method Mean Error StdDev Ratio RatioSD
'UUIDv7 new instance generation test' 1,642.8 ns 17.82 ns 15.79 ns 12.36 0.17
'GUID new instance generation test' 133.0 ns 1.12 ns 1.05 ns 1.00 0.00
Method Mean Error StdDev Median Ratio RatioSD
'UUIDv7 parse byte array test' 3,302.2 ns 77.95 ns 218.57 ns 3,300.0 ns 23.91 8.29
'GUID parse byte array test' 155.0 ns 16.96 ns 50.00 ns 200.0 ns 1.00 0.00

Contribution

uuid_dotnet's People

Contributors

glgarg avatar mrzoidberg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.