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.
dotnet add package Genetom.ULIDusing Genetom.ULID;
// One time initialization in program.cs
GenetomULID.SetServerId(12); // Optional , Default serverId is 0
long id = GenetomULID.GenerateId64();
Console.WriteLine(id);| Bits | Field | Description |
|---|---|---|
| 41 | Timestamp | Milliseconds since custom epoch |
| 10 | Server ID | Unique per server (0–1023) |
| 12 | Sequence | Counter per millisecond (0–4095) |
| 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 | - | - |
MIT