Skip to content

Switch to ByteAether.Ulid for faster, always‑reliable ULID generation #204

@Seramis

Description

@Seramis

Hello!

First and foremost, thank you for the excellent work you've put into this project.

Please excuse the unsolicited suggestion. I was looking at the project dependencies and it started me thinking about the nuances of different ULID library implementations. Depending on the specific library in use, a couple of common issues can sometimes arise, and I wanted to share a thought in case it's helpful.

Many libraries have different approaches to the ULID specification, which can lead to a couple of potential outcomes:

  1. Incorrect Monotonicity: Some libraries don't strictly enforce monotonicity. This can cause problems in systems that rely on the sortable nature of ULIDs, as it can result in out-of-order IDs being generated, especially under high load.
  2. Overflow Exceptions: Other libraries, while adhering strictly to the spec, are designed to throw an exception if the random component overflows during high-frequency generation. This is a safety measure, but in a high-throughput scenario, it could unexpectedly halt ID issuance altogether.

To solve these exact problems, I ended up developing my own implementation. As a point of full transparency, I am the author of the library I'm about to suggest, called ByteAether.Ulid. I'm proposing it because I built it specifically to be a reliable and performant solution for these scenarios, and I thought it might be of value to this project.

A couple of key benefits:

  • Guaranteed Monotonicity without Exceptions: Instead of throwing an error on overflow, it gracefully increments the 48-bit timestamp. This ensures IDs are always sortable and that generation never fails unexpectedly.
  • Top-Tier Performance: It's benchmarked as being exceptionally fast and memory-efficient (zero allocation on generation), which is always beneficial.

If you're curious and have a moment, here are the links for your consideration:

Again, I hope this comes across as a helpful suggestion from one developer to another.

Thanks for your time and for all your efforts on this great project!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions