\Drupal\strata\Delta ChainDepthPolicy

Decides when a delta chain must be broken by a self-contained frame.

Delta coding is what makes a rewritten value cheap: measured on 5,967-byte user notification blobs with one flag flipped and one entry appended, compressing against the previous version reached 63.70x where standalone compression reached 4.49x - 94 bytes against 1,330.

The cost is a dependency. Frame N decodes only if frame N-1 is present and intact, so an unbounded chain turns one lost frame into an unbounded loss and makes restore latency grow without limit. Git solves the same problem in its packfiles with pack.depth, default 50. Strata's default is 32, chosen lower because a restore here walks the chain synchronously while a user waits, and because the marginal ratio past ~30 links is small against the marginal risk.

A chain break is called an anchor: a frame encoded standalone, which any later frame can be rebuilt from without reaching further back.

Summary

Methods
Properties
Constants
__construct
maxDepth
mustAnchor
nextDepth
remaining
No public properties found
DEFAULT_MAX_DEPTH
HARD_MAX_DEPTH
No protected methods found
No protected properties found
No protected constants found
No private methods found
maxDepth
No private constants found

Constant

DEFAULT_MAX_DEPTH

DEFAULT_MAX_DEPTH = 32

Chain depth Strata ships with.

HARD_MAX_DEPTH

HARD_MAX_DEPTH = 256

Deepest chain that may be configured.

Past this the restore-latency and blast-radius costs above grow without bound.

Properties

$maxDepth

$maxDepth : int

Maximum links between anchors.

Type

int

Methods

__construct()

__construct(int  $maxDepth = \self::DEFAULT_MAX_DEPTH) : mixed

Constructs a policy.

Parameters

int $maxDepth

Maximum chain depth, between 0 and ChainDepthPolicy::HARD_MAX_DEPTH. Zero means every frame is an anchor, which is the correct setting for a store that values restore latency over size.

Throws

\InvalidArgumentException

When $maxDepth is negative or above the hard maximum.

Returns

mixed —

maxDepth()

maxDepth() : int

The configured maximum depth.

Returns

int —

Maximum links between anchors.

mustAnchor()

mustAnchor(int  $parentDepth) : bool

Whether a frame at this parent depth must be written standalone.

Parameters

int $parentDepth

The depth of the frame this one would be encoded against.

Throws

\InvalidArgumentException

When $parentDepth is negative.

Returns

bool —

TRUE when the new frame must be an anchor.

nextDepth()

nextDepth(int  $parentDepth) : int

The depth a new frame would have.

Parameters

int $parentDepth

The depth of the frame this one is encoded against.

Throws

\InvalidArgumentException

When $parentDepth is negative.

Returns

int —

Zero when the frame must anchor, otherwise one past the parent.

remaining()

remaining(int  $depth) : int

How many more links a chain at this depth can take.

Surfaced so the UI can show headroom rather than only reporting the break after it happens.

Parameters

int $depth

Current chain depth.

Throws

\InvalidArgumentException

When $depth is negative.

Returns

int —

Remaining links before the next anchor, never negative.