Skip to content

High-performance 64-bit ULID (32-bit,128-bit in future) generator for distributed systems with timestamp, server ID, and sequence support

License

Notifications You must be signed in to change notification settings

ThiruDev50/Genetom.ULID

Repository files navigation

GenetomULID

NuGet Version NuGet Downloads

GenetomULID is a high-performance 64-bit ULID generator for distributed systems.
It uses a compact bit layout:

  • 41 bits → Timestamp (milliseconds since custom epoch)
  • 10 bits → Server/Machine ID
  • 12 bits → Sequence per millisecond

This allows up to 4096 IDs per server per millisecond and supports 1024 unique servers in a cluster.


📦 Installation

dotnet add package Genetom.ULID

NuGet Package Link


🚀 Usage

using Genetom.ULID;

// One time initialization in program.cs
GenetomULID.SetServerId(12); // Optional , Default serverId is 0

long id = GenetomULID.GenerateId64();

Console.WriteLine(id);

⚙️ Bit Layout

Bits Field Description
41 Timestamp Milliseconds since custom epoch
10 Server ID Unique per server (0–1023)
12 Sequence Counter per millisecond (0–4095)

📊 Benchmark (BenchmarkDotNet)

Method Mean Error StdDev Gen0 Allocated
GenetomULID_GenerateId64 33.21 ns 0.571 ns 0.506 ns 0.0038 32 B
GenerateGUID 39.02 ns 0.798 ns 0.980 ns - -

📝 License

MIT

About

High-performance 64-bit ULID (32-bit,128-bit in future) generator for distributed systems with timestamp, server ID, and sequence support

Topics

Resources

License

Stars

Watchers

Forks

Languages