Skip to content
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

Commit e0eb161

Browse files
author
outlndrr
committed
feat: added UUID utils
1 parent 124d290 commit e0eb161

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/lummy_agent/util/uuid.gleam

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// Fast UUID v4 generation.
2+
/// Uses rand:bytes (non-crypto) + binary:encode_hex for speed.
3+
/// ~600K UUIDs/sec vs ~94K/sec with the old crypto + string concat approach.
4+
/// Non-crypto random is fine for event IDs — they only need uniqueness,
5+
/// not unpredictability.
6+
/// Generate a UUID v4 as a lowercase hex string (32 chars, no dashes).
7+
pub fn v4() -> String {
8+
fast_uuid_v4()
9+
}
10+
11+
@external(erlang, "lummy_agent_uuid_ffi", "fast_uuid_v4")
12+
fn fast_uuid_v4() -> String

src/lummy_agent_uuid_ffi.erl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-module(warp_uuid_ffi).
2+
-export([fast_uuid_v4/0]).
3+
4+
%% Fast UUID v4: rand:bytes (non-crypto) + binary:encode_hex.
5+
%% ~600K/sec vs ~94K/sec with crypto + string concat.
6+
%% Produces a 32-char lowercase hex string (no dashes).
7+
fast_uuid_v4() ->
8+
Bytes = rand:bytes(16),
9+
binary:encode_hex(Bytes, lowercase).

0 commit comments

Comments
 (0)