-
Notifications
You must be signed in to change notification settings - Fork 183
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
Reduce checkpoint file size by using fewer bytes to encode length of encoded payload value #2165
Conversation
In v0, length of encoded payload value is encoded in 8 bytes. In v1, length of encoded payload value is encoded in 4 bytes. Payload decoding handles both v0 and v1. Payload is encoded according to version received as parameter. This allows gradual migration of other encoding formats using payload, such as TrieUpdate and TrieProof.
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.
looks good to me
Bump version of checkpoint file to v5. Support reading v4 for compatibility. Add tests and test data to read v4.
Update checkpoint file format version from v4 to v5
encMaxDepthSizeV4 = 2 | ||
encRegCountSizeV4 = 8 | ||
encHashSizeV4 = hash.HashLen | ||
encPathSizeV4 = ledger.PathLen |
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.
👌🏼 for using the constants
if err != nil { | ||
log.Fatal().Err(err).Msg("invalid root checkpoint") | ||
} | ||
} else { |
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.
I think I left this comment on other PR - I would check if version is below one we explicitly support
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.
Description
Encode length of encoded payload value using 4 bytes (instead of 8 bytes) because the entire payload length is encoded to only 4 bytes.
This encoding is used in checkpoint, TrieUpdate (WAL), and TrieProof. Since this change affects code outside checkpoint, it was moved from PR #1944 to this PR.
Thanks @ramtinms and @tarakby for confirming we should reduce this length.
Closes #2070
Updates #1884
Updates https://github.com/dapperlabs/flow-go/issues/6114
Changes include:
Add payload encoding v1 to encode length of encoded payload value to 4 bytes. In v0, length of encoded payload value is encoded in 8 bytes.
Support decoding both v0 and v1.
Support version parameter for payload encoding. This allows gradual migration of other encoding formats using payload, such as TrieUpdate and TrieProof.
Caveats
This PR optimizes checkpoint file size which should reduce memory use. This isn't expected to have a big impact on speed. Other possible optimizations are outside the scope of this PR.