Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Provide a faster alternative to UUID #12

Open
Stebalien opened this issue Nov 15, 2017 · 3 comments
Open

Provide a faster alternative to UUID #12

Stebalien opened this issue Nov 15, 2017 · 3 comments

Comments

@Stebalien
Copy link
Member

UUIDs are slow. They require allocation and a systemcall. We should be using an instance unique UUID plus a global counter:

type EventId struct {
    Inst: UUID // we can rotate this if we overflow uint64.
    Ctr: uint64
}
@Kubuxu
Copy link
Member

Kubuxu commented Nov 15, 2017

@Stebalien uuid lib we are using uses crypt/rand for uuid generation: https://github.com/satori/go.uuid/blob/master/uuid.go#L113-L117

@Stebalien
Copy link
Member Author

Yep. On Linux, at least, that always makes a systemcall (although I guess it doesn't allocate, it uses a fixed size byte array). Systemcalls are expensive. For now, we aren't doing anything where this would make a difference. However, if we switch to an RPC-based API with suffucient buffering, we could theoretically get down to <1 syscall per RPC. At that point, generating a UUID becomes expensive.

@Kubuxu
Copy link
Member

Kubuxu commented Nov 15, 2017

That is true, Read from crypt/rand uses getrandom(2).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants