The bitmop layer has been rewritten around ByteBuffer-based primitives and JVM intrinsics, delivering substantial performance gains across the board with no changes to the public API.
mask-offset, mask-width, and bit-count now compile to single
hardware instructions (TZCNT, POPCNT) via Long/numberOfTrailingZeros
and Long/bitCount, replacing the previous O(n) loops.
A new ByteBuffer abstraction (uuid->buf, buf->uuid) provides
direct typed access at byte offsets via native getLong/putLong
operations, eliminating manual shift/mask loops for serialization.
Representative speedups over 0.2.0:
| Category | Speedup |
|---|---|
to-byte-array | 57x |
to-hex-string | 29x |
| v3 (MD5) generation | 9.0x |
| v5 (SHA1) generation | 6.0x |
| v8 (custom) generation | 4.2x |
| v1 (time-based) generation | 1.5x |
| v6 (time-based) generation | 1.4x |
Combined generate + serialize operations see 3-19x end-to-end improvement depending on UUID version and serialization format.
v3/v5 generation now uses a fused digest pipeline with ThreadLocal
ByteBuffer reuse, ByteBuffer/wrap on digest output, and inlined
version/variant bit stamping -- eliminating all intermediate
allocations and var lookups. v5 is now at parity with JUG 5.2
(~260 ns vs ~254 ns).
get-clk-seq now uses bitmop/ldb to extract the 14-bit clock
sequence directly, fixing incorrect results that occurred when
Java's .clockSequence() method threw on non-v1 UUIDs.AtomicLong with
compareAndSet on a packed long (50-bit millis + 14-bit seqid),
replacing atom + swap! + per-call State allocation.ldb/dpb overhead
on the hot path.+max+, max, max?)v7nc uses ThreadLocalRandom and a per-thread monotonic counter
instead of SecureRandom and a global AtomicLong. At ~39 ns/op,
it is 1.26x faster than JUG 5.2's TimeBasedEpochGenerator
(~50 ns/op).
get-instant -- returns a java.util.Date for time-based UUIDsget-unix-time -- returns POSIX millis for v1, v6, and v7get-clk-seq -- returns the 14-bit clock sequence for v1 and v6to-hex-string -- 32-character hex encoding (no dashes)to-uri -- returns java.net.URI in URN formatmax? -- predicate for the max UUIDUUIDRfc9562 protocol (with UUIDRfc4122 as a backward-compatible alias)v0 / null -- null UUID constructormax -- max UUID constructorv4 two-arity form (v4 msb lsb) -- stamps version and variant bits onto
caller-supplied words=, <, > comparison operatorsas-uuid now accepts java.net.URI, byte arrays, and URN strings
in addition to canonical UUID stringsuuidable? predicate for testing coercibilitydeps.edn for tools.deps / CLI users.travis.yml; CI now uses GitHub Actionsget-timestamp, approximately,
associated, requirements, consciousness, alphabetically,
elapsed, duplicate, construction)Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |