MonotonicUlid vs Ulid
See original GitHub issueCan you please tell me the use cases where a “non-monotonic” Ulid should be preferred over a “monotonic” Ulid? I expected that the generation of a MonotonicUlid
is much slower than a non-monotonic Ulid, but according to the benchmark, MonotonicUlid
are much faster than non-monotonic Ulids created by UlidCreator.getUlid()
.
Ulid_fast thrpt 5 34523,147 ± 1022,114 ops/ms (9.98)
Ulid_fast_toString thrpt 5 19161,375 ± 662,563 ops/ms
- - - - - - - - - - - - - - - - - - - - - - - - - - -
UlidCreator_getUlid thrpt 5 4276,614 ± 11,069 ops/ms (1.23)
UlidCreator_getUlid_toString thrpt 5 3645,088 ± 85,478 ops/ms
- - - - - - - - - - - - - - - - - - - - - - - - - - -
UlidCreator_getMonotonicUlid thrpt 5 32921,698 ± 1286,983 ops/ms (9.51)
UlidCreator_getMonotonicUlid_toString thrpt 5 18541,252 ± 710,281 ops/ms
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How probable are collisions with ULID's monotonic option?
ULID features a monotonic option, but we had concerns about whether using it increased the probability of collisions.
Read more >ULID vs UUID: Sortable Random ID Generators for JavaScript
Monotonic ULIDs & Seed Time. ULID allows you to get IDs with the same timestamp by passing a seed time. For example, if...
Read more >The canonical spec for ulid - GitHub
Universally Unique Lexicographically Sortable Identifier. UUID can be suboptimal for many use-cases because: It isn't the most character efficient way of ...
Read more >ULID — Universally Unique Lexicographically Sortable Identifier
ULID ensures that the IDs can be monotonically ordered and can be sorted even when generated within a millisecond.
Read more >ULIDs and Primary Keys - Dave Allie
A ULID is a 128-bit label, just like a UUID. It's sortable, has millisecond precision, and is monotonically increasing, just like UUIDv7.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh yes the
synchronized
makes it slower. Good to know. Thanks!I implemented now the
Ulid.fastMonotonic()
method to test whether it is worth having a monotonic generator withSplittableRandom
.But the throughput of
Ulid.fastMonotonic()
is worse (-26% less) thanUlid.fast()
;As you can see there is no performance gain, but contrary to what we expect. So I think it’s not useful because you have to synchronize the
Ulid.fastMonotonic()
method.