Skip to main content

Module subtree

Module subtree 

Source
Expand description

SubtreePrefetch sync types (CIP Appendix B - Protocol Selection Matrix).

Types for subtree prefetch-based synchronization, optimized for deep trees with clustered changes.

§When to Use

  • max_depth > 3 (deep trees)
  • divergence < 20%
  • Changes are clustered in subtrees

§Trade-offs

AspectHashComparisonSubtreePrefetch
Round tripsO(depth)O(1) per subtree
Data transferMinimalMay over-fetch
Best forScattered changesClustered changes

§Validation

All types have is_valid() methods that should be called after deserializing from untrusted sources to prevent resource exhaustion attacks.

Structs§

SubtreeData
Data for a single subtree.
SubtreePrefetchRequest
Request for subtree prefetch-based sync.
SubtreePrefetchResponse
Response containing prefetched subtrees.

Constants§

DEEP_TREE_THRESHOLD
Minimum tree depth to consider SubtreePrefetch over HashComparison.
DEFAULT_SUBTREE_MAX_DEPTH
Default maximum depth for subtree prefetch.
MAX_CLUSTERED_SUBTREES
Maximum number of differing subtrees for changes to be “clustered”.
MAX_DIVERGENCE_RATIO
Maximum divergence ratio for SubtreePrefetch to be efficient.
MAX_ENTITIES_PER_SUBTREE
Maximum number of entities per subtree.
MAX_SUBTREES_PER_REQUEST
Maximum number of subtree roots in a single request.
MAX_SUBTREE_DEPTH
Maximum allowed depth for subtree traversal requests.
MAX_TOTAL_ENTITIES
Maximum total entities across all subtrees in a response.

Functions§

should_use_subtree_prefetch
Compare HashComparison vs SubtreePrefetch for a given scenario.