Skip to content

export: don't export branch node's key in snapshot #688

@yihuang

Description

@yihuang

in IAVL, a branch node's key is always the smallest leaf key in it's right branch, the key can be infered during the import process, so no need to include it in the snapshot at all.

Migration process

  • Step 1, change the import logic to derive the branch node's key on the fly, ignore the one included in the snapshot, this is not a consensus breaking change.
  • Step 2, change the export logic to skip branch node's key, this should be considered as a breaking change and need a coordinated upgrade, so the snapshots created after the upgrade are updated consistently across the network.

Do we need to update the snapshot format version for this?

Consequences

Positives

  • Reduce snapshot size, say L is the number of leave nodes, previously we export 2 * L - 1 keys and L values, now we export L keys and L values, if key and value are the same length on average, it reduces 30% size of snapshot.
  • In the future, can apply delta encoding to the leaf keys to further reduce snapshot size, since the leaf keys are exported in order, apply delta encoding to it should produce very good compression rate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions