Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move node_id generation into State (#2401) #2401

Merged
merged 14 commits into from
Oct 7, 2023
Merged

Move node_id generation into State (#2401) #2401

merged 14 commits into from
Oct 7, 2023

Conversation

panh99
Copy link
Contributor

@panh99 panh99 commented Sep 20, 2023

Description

This PR does two things: 1) generate node_id and workload_id as a random 64-bit unsigned integer instead of a positive int64; 2) move the generation of node_id code into state.
However, it may not be super necessary to use "real" uint64, given that sqlite3 does not natively support uint64. We can always use 63 bits instead of all 64 bits if the information loss due to 1 bit less is trivial.

Refactoring State.register_node(self, node_id: int) -> None and State.unregister_node(self, node_id: int) -> None to State.create_node(self) -> int and State.delete_node(self, node_id: int) -> None. The two methods are renamed to fit their new functionalities.

Move the node_id generation within the State.create_node().

Make node_id true uint64, via random.getrandbits(64).

Update InMemoryState and SqliteState.

Store uint64 values as int64 in SqliteState and convert them back to uint64 on retrieval.

Update corresponding tests, comments, names, and protocols.

Copy link
Member

@danieljanes danieljanes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@danieljanes danieljanes changed the title Move node_id generation to state and make workload_id & node_id uint64 Move node_id generation into State (#2401) Oct 7, 2023
@danieljanes danieljanes merged commit c4a8876 into main Oct 7, 2023
26 checks passed
@danieljanes danieljanes deleted the update-id-gen branch October 7, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants