Replace using UUIDs with a consistent eventmaker#232
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
eabfda7 to
032c2ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: #139
UUIDs are hella expensive for what we need, and we are sort of inconsistent about how event ids are declared. additionally, making events is sort of cumbersome, so it would be nice to have a simple factory class to wrap up some of the repeated boilerplate there too.
the requirements for event ids are pretty simple:
Just doing a simple 64-bit integer format where the first 32 bits are some random prefix, and the last 32 bits are a sequence. This gets us out of the trap of everyone just using a
count()and having them all overlap (e.g. in the zmqrunner) while still being pretty cheap - we only need randomness once, at init time, and that's pretty quick, rather than every time.I initially made a subclass of
intthat had properties to get the prefix and sequence numbers, but that was too slow, so i just went with a bare int with accessory construction and deconstruction methodsuuid.uuid4()EventID.from_prefix(12345, next(counter))event_id(12345, next(counter))event_id(12345, 5789)event_id(shifted, 5789, shifted=True)so ~25x faster for an operation we do literally all the time.
📚 Documentation preview 📚: https://noob--232.org.readthedocs.build/en/232/