I created a Delphi implementation of ULID - A Universally Unique Lexicographically Sortable Identifier. ULID’s are a better option than GUIDs where sorting is needed
128-bit compatibility with UUID
1.21e+24 unique ULIDs per millisecond
Lexicographically sortable!
Canonically encoded as a 26 character string, as opposed to the 36 character UUID
Uses Crockford’s base32 for better efficiency and readability (5 bits per character)
Case insensitive
No special characters (URL safe)
Monotonic sort order (correctly detects and handles the same millisecond)
@sglienke had a look at my code and with few suggestions it’s now a lot faster - even with some added validation to the base32 strings passed to the parse method.
That made me laugh. I used to do a talk for the ukDevGroup once a year where I would show some code and encourage the attendees to should “That’s ”, but then they had to suggest how to improve it. So to be clear. this is an alternative to GUID for databases. … and the of “Lexicographically sortable!” - i.e. what does it actually mean?
It’s a fancy way of saying you can use them for a primary key, and the order makes sense when sorted. The timestamp component is what gives it the order.
Stefan understands x86/64 assembly really well (and the performance of instructions) - and spends a lot of time looking at the code generated by the delphi compilers - so he was able to give advice on a few things that impact performance. The net result was going from 16M generations p/s to 100M p/s (x64). Pretty impressive. I told him he should write a book!