The first two posts made history readable. This one covers what makes a data version system actually useful: branches and changes.

1. The branch model

A branch isn’t “a copy of the data”; it’s a combination of three things:

branch = pin (which commit) + name + lineage (parent / base_line)
       + optional storage (materialized copy) or delta (changes relative to a base)
  • materialize: really copy the table; reads go straight to the copy;
  • delta: store only “which keys were removed from the base, which rows were added”; reads compose;
  • update in a delta is a removal plus an addition of the same key (replacement pairing).

This design brings the cost of “create a branch” from “copy a table” down to “register one metadata row.”

2. diff: two paths, one goal

diff finds the difference between two references. We ended up with two paths:

PathTriggerApproach
row-id pathSame table, neither side has a deltaCompare row ids and visibility directly, O(rows)
key pathDifferent tables, or either side has a deltaAlign on the primary key (integer keys use a bit-pattern fast path)

Memory is a measured ceiling:

ScenarioPeak RSSTime
1M rows, cross-table key path344 MB6.2 s
1M rows, same-table row-id path248 MB—
400K-row delta self-diff151 MB—

Broken down, the key path’s own structures are about 133 B/row (arena ~50, hash table ~40, columns ~10). This isn’t “maybe squeeze a bit more” — at 10M rows it’s gigabytes, so the conclusion is: write the diff’s scale limit into the docs instead of pretending it’s unbounded.

3. pick, merge, clone, PITR

  • pick: apply a reference’s changes onto the current branch, with conflict policies (FAIL / SKIP / ACCEPT);
  • merge: three-way merge (base, left, right), policies configurable;
  • clone: file-level zero-copy via clonefile / FICLONE, measured as essentially free;
  • PITR: point-in-time recovery by choosing the newest reference at or before T;
  • quotas: limit the number of snapshots/branches.

One interesting measured comparison (1M rows):

OperationTimeMemory
Materialize a full copy0.16 s45 MB
Write a 50% delta2.22 s114 MB
Read the copy0.02 s26 MB
Read the delta1.90 s58 MB

Conclusion: sparse changes favor delta; dense changes favor a copy. This replaced our initial — wrong — intuition that “delta is always cheaper,” and went into the design note.

4. Verification discipline: the revert check

The hardest part of this feature isn’t writing code — it’s proving it isn’t wrong. We established a discipline whose most important rule is the revert check:

Every fix must make a named test line fail when the fix is removed.

Examples:

  • Remove the “pin blocks appends” fix → a retention test reads 610K rows instead of 600K;
  • Remove the “key-path diff” → merge silently loses a change;
  • Remove the “merge ancestor guard” → merge silently succeeds and reverts the ancestor.

Without this rule you can’t tell “fixed” from “not covered by a test yet.”

5. Test scale

Final feature test set:

SuiteScale
git4data feature tests85 files / 4,592 assertions
Storage suite655 cases / 102,325 assertions
Index suite151 cases / 85,991 assertions
Full regression7,341 cases (0 feature-related failures)

Plus four build axes (Release / FORCE_ASSERT / ALTERNATIVE_VERIFY / config sweep) and a set of scripts (74 retention checks, 47 crash-consistency checks, 34 MatrixOne parity checks…).

6. Summary

  • A branch is “reference + lineage,” not “copy of data”;
  • diff has two paths; its scale limit must be measured and written down;
  • delta vs copy depends on change density — measure, don’t assume;
  • the revert check is a version control system’s own unit test.

Next: moving the registry out of the checkpoint metadata block into ordinary tables — transactions, crash consistency, and “hidden but readable.”

Get the next essay

New essays on products, business and tech — plus what the experiment's numbers actually say.