2 ms·
I've been doing this for years in projects internal to my employers. It's nice to see it catching on, because it'll be easier to explain to people if I can poin
by fl0ki 2y ago
I've been doing this for years in projects internal to my employers. It's nice to see it catching on, because it'll be easier to explain to people if I can point to a blog post saying the same thing.
Other tips worth trying:
* You'll do even better by optimizing your ID type. Even if it has to be a string, it can at least be a string with SSO, or a long-lived string reference, or an interned string.
* Try the ahash crate instead of the default cryptogically secure hash function in Rust.
* Consider HashSet<ByRef<Arc<T>>> instead of having to take keys to a different map to resolve the actual object.
- o11c 2y ago* You can use a Vector-like for the `uid_to_did` direction (be sure it doesn't copy on resize, and you may also want to prevent invalidation, so a 2-level vector is often a reasonable choice). Depending on design decisions the elements might want to be `Option<String>` instead of just `String`. * You can get away with uint32 indexes. The interned indexes should local so this shouldn't be a problem even if you think you'll have more than 4 billion global users. (note: all social media combined only has that currently) * For interned strings specifically it's embarrassingly simple to use a bump allocator for the string data itself.