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

Omit empty next slab ID in encoded map data slab #340

Conversation

fxamacker
Copy link
Member

@fxamacker fxamacker commented Sep 5, 2023

Updates #292 onflow/flow-go#1744

Changes:

Currently, we omit empty next slab ID in encoded root data slabs because next slab ID is always empty in root data slabs.

However, next slab ID is also empty for non-root data slabs if the non-root data slab is the last data slab.

This commit sets hasNextSlabID flag during encoding and only encodes non-empty next slab ID for map data slab.

This change saves 16 bytes for the last non-root data slabs. Also, we don't special case the omission of next slab ID in root slabs.

NOTE: omission of empty next slab ID doesn't affect slab size computation which is used for slab operations, such as splitting and merging. This commit is a size optimization during slab encoding.


  • Targeted PR against main branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Currently, we omit empty next slab ID in encoded root data slabs
because next slab ID is always empty in root data slabs.

However, next slab ID is also empty for non-root data slabs if
the non-root data slab is the last data slab.

This commit sets hasNextSlabID flag during encoding and only encodes
non-empty next slab ID for map data slab.

This change saves 16 bytes for the last non-root data slabs.  Also,
we don't special case the omission of next slab ID in root slabs.

NOTE: omission of empty next slab ID doesn't affect slab size
computation which is used for slab operations, such as splitting and
merging.  This commit is an optimization during slab encoding.
@fxamacker fxamacker added the enhancement New feature or request label Sep 5, 2023
@fxamacker fxamacker self-assigned this Sep 5, 2023
@fxamacker fxamacker merged commit cf56a4c into fxamacker/remove-empty-next-slab-id-in-encoded-array-data Sep 12, 2023
3 checks passed
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants