Copy-on-Write Branch / Snapshot

Problem

Implement copy-on-write branching: branching a dataset shares pages until one branch writes, then copies the page (instant DB branching).

Input / Output

  • Input: a dataset and branch() / write operations against branches.
  • Output: independent logical branches that share physical storage until they diverge.

Constraints

  • O(1) branch; copy only on write.

Example

branch() shares pages; write on branch copies only that page
added …
LeaderboardSalaryAccount