-
Notifications
You must be signed in to change notification settings - Fork 4.5k
uses varint encoding for vote-state lockout offsets #27565
uses varint encoding for vote-state lockout offsets #27565
Conversation
4d8b4e8
to
5ac0de1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since offset already has known bounds does this save us much vs using fixed? And is there a performance hit when serializing / deserializing varints?
Makes the code cleaner so I think it's a better solution, curious about the metrics.
sdk/program/src/vote/state/mod.rs
Outdated
#[serde(with = "serde_varint")] | ||
offset: Slot, | ||
#[serde(with = "serde_varint")] | ||
confirmation_count: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be u8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
any reason the original VoteStateUpdate
defines a u32
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was copied over from the original Vote
which defined confirmation_count
as u32
. @carllin was there a specific reason for that?
Cool stuff, would be good to get a size comparison between this and the existing compactvotestate for a full tower (i.e. a vote with 32 slots) |
e773a65
to
0b286a7
Compare
yeah, might not save much. It depends on the actual value of offsets. On the other hand there are instances we might need an extra byte due to most significant bit being used for varint encoding. The commit also removes |
df33dfa
to
c45e3c9
Compare
Collected some data comparing the encoding methods with a validator running on testnet. Here's the average serialized size of vote state for each (sample size of 57k votes observed):
I was seeing very little variation for each. Very sparingly size would dip to the following minimum values
Data can be found here. |
c45e3c9
to
d67885f
Compare
Pull request has been modified.
8560158
to
64f5df1
Compare
#[derive(Deserialize, Serialize)] struct Foo { #[serde(with = "serde_varint")] field: u64, ... }
The commit removes CompactVoteStateUpdate and instead reduces serialized size of VoteStateUpdate using varint encoding for vote-state lockout offsets.
64f5df1
to
098391f
Compare
…#27727) * adds serde varint encoder/decoder #[derive(Deserialize, Serialize)] struct Foo { #[serde(with = "serde_varint")] field: u64, ... } (cherry picked from commit f6fbc47) * uses varint encoding for vote-state lockout offsets The commit removes CompactVoteStateUpdate and instead reduces serialized size of VoteStateUpdate using varint encoding for vote-state lockout offsets. (cherry picked from commit 4f22ee8) # Conflicts: # core/src/consensus.rs # programs/vote/src/vote_instruction.rs # programs/vote/src/vote_state/mod.rs # sdk/program/src/vote/state/mod.rs * removes mergify merge conflicts Co-authored-by: behzad nouri <[email protected]>
Problem
VoteStateUpdate
has large serialized size.Summary of Changes
The commit removes
CompactVoteStateUpdate
and instead reduces serializedsize of
VoteStateUpdate
using varint encoding for vote-state lockoutoffsets.