{
  "schemaVersion": 1,
  "kind": "constructed-byte-accounting-examples",
  "generatedAt": "2026-10-19T21:25:32.288Z",
  "runtime": {
    "node": "v24.21.0",
    "dependencies": "none",
    "seed": "not applicable"
  },
  "license": "CC0-1.0 for original code and examples; source paper retains its rights",
  "humanPage": "https://hesela.com/analyses/key-value-separation-cleaning-cost/#batch-accounting",
  "source": {
    "title": "Rosenblum and Ousterhout, The Design and Implementation of a Log-Structured File System, TOCS 10(1), 1992, pp. 26-52, section 3.4",
    "url": "https://web.stanford.edu/~ouster/cgi-bin/papers/lfs.pdf",
    "accessed": "2026-10-19"
  },
  "method": "For chosen regions, sum size S and surviving bytes L. Reclaimed D=S-L. Move L bytes once and refill D bytes once. Writes=S; total transfers=readBytes+S. Divide both by D. No victim-selection simulation.",
  "units": "Every *Bytes field is an integer byte count. One MiB is 1048576 bytes. Ratios and fractions are dimensionless.",
  "fields": {
    "regions": "Constructed inputs: bytes is selected region size, liveBytes is its survivor count.",
    "regionCount": "Number of selected regions.",
    "readMode": "scan-all reads every selected byte; skip-known-empty omits only regions with zero survivors.",
    "selectedBytes": "Sum of selected region sizes S.",
    "relocatedBytes": "Sum of surviving bytes L, copied once.",
    "reclaimedBytes": "Net free space D=S-L before refill; denominator for both ratios.",
    "readBytes": "Modeled whole-region reads under the specified read policy.",
    "writtenBytes": "Survivor writes plus refill writes L+D=S; excludes index and WAL writes.",
    "transferredBytes": "readBytes+writtenBytes.",
    "byteWeightedLiveFraction": "L/S; weights each region's live fraction by its size.",
    "unweightedLiveFraction": "Arithmetic mean of the region live fractions; diagnostic only.",
    "logWriteRatio": "writtenBytes/D; null when D=0.",
    "totalTransferRatio": "transferredBytes/D; null when D=0. Not a latency or speedup measurement."
  },
  "limitations": [
    "Invented byte counts, not measured devices, traces, populations or confidence intervals.",
    "Assumes no new invalidations during the batch, size-preserving relocation, no deduplication and full refill.",
    "Does not price index updates, WAL, metadata, seeks, compression, alignment, caching or NAND behavior.",
    "Skipping empty regions assumes their emptiness is already known correctly; proving it is outside the model.",
    "Existing 30-row KV model has a different boundary, including index writes; its files and API are preserved."
  ],
  "modelSha256": "f960c52f20acb149da6909085a4fb5c91284408472482cd8a2afb33e2ade4e98",
  "generatorSha256": "40fb22df560440f2b5b1672c10d60d25f08ba24c2164781b91027f6f62011947",
  "rows": [
    {
      "id": "equal",
      "label": "Equal-size regions",
      "regions": [
        {
          "bytes": 52428800,
          "liveBytes": 5242880
        },
        {
          "bytes": 52428800,
          "liveBytes": 47185920
        }
      ],
      "readMode": "scan-all",
      "regionCount": 2,
      "selectedBytes": 104857600,
      "relocatedBytes": 52428800,
      "reclaimedBytes": 52428800,
      "readBytes": 104857600,
      "writtenBytes": 104857600,
      "transferredBytes": 209715200,
      "byteWeightedLiveFraction": 0.5,
      "unweightedLiveFraction": 0.5,
      "logWriteRatio": 2,
      "totalTransferRatio": 4
    },
    {
      "id": "larger-live",
      "label": "Larger region mostly live",
      "regions": [
        {
          "bytes": 20971520,
          "liveBytes": 2097152
        },
        {
          "bytes": 83886080,
          "liveBytes": 75497472
        }
      ],
      "readMode": "scan-all",
      "regionCount": 2,
      "selectedBytes": 104857600,
      "relocatedBytes": 77594624,
      "reclaimedBytes": 27262976,
      "readBytes": 104857600,
      "writtenBytes": 104857600,
      "transferredBytes": 209715200,
      "byteWeightedLiveFraction": 0.74,
      "unweightedLiveFraction": 0.5,
      "logWriteRatio": 3.8461538461538463,
      "totalTransferRatio": 7.6923076923076925
    },
    {
      "id": "larger-dead",
      "label": "Larger region mostly obsolete",
      "regions": [
        {
          "bytes": 83886080,
          "liveBytes": 8388608
        },
        {
          "bytes": 20971520,
          "liveBytes": 18874368
        }
      ],
      "readMode": "scan-all",
      "regionCount": 2,
      "selectedBytes": 104857600,
      "relocatedBytes": 27262976,
      "reclaimedBytes": 77594624,
      "readBytes": 104857600,
      "writtenBytes": 104857600,
      "transferredBytes": 209715200,
      "byteWeightedLiveFraction": 0.26,
      "unweightedLiveFraction": 0.5,
      "logWriteRatio": 1.3513513513513513,
      "totalTransferRatio": 2.7027027027027026
    },
    {
      "id": "empty-scan",
      "label": "Empty region scanned",
      "regions": [
        {
          "bytes": 104857600,
          "liveBytes": 0
        }
      ],
      "readMode": "scan-all",
      "regionCount": 1,
      "selectedBytes": 104857600,
      "relocatedBytes": 0,
      "reclaimedBytes": 104857600,
      "readBytes": 104857600,
      "writtenBytes": 104857600,
      "transferredBytes": 209715200,
      "byteWeightedLiveFraction": 0,
      "unweightedLiveFraction": 0,
      "logWriteRatio": 1,
      "totalTransferRatio": 2
    },
    {
      "id": "empty-skip",
      "label": "Known-empty region skipped",
      "regions": [
        {
          "bytes": 104857600,
          "liveBytes": 0
        }
      ],
      "readMode": "skip-known-empty",
      "regionCount": 1,
      "selectedBytes": 104857600,
      "relocatedBytes": 0,
      "reclaimedBytes": 104857600,
      "readBytes": 0,
      "writtenBytes": 104857600,
      "transferredBytes": 104857600,
      "byteWeightedLiveFraction": 0,
      "unweightedLiveFraction": 0,
      "logWriteRatio": 1,
      "totalTransferRatio": 1
    },
    {
      "id": "no-reclaim",
      "label": "All bytes still live",
      "regions": [
        {
          "bytes": 104857600,
          "liveBytes": 104857600
        }
      ],
      "readMode": "scan-all",
      "regionCount": 1,
      "selectedBytes": 104857600,
      "relocatedBytes": 104857600,
      "reclaimedBytes": 0,
      "readBytes": 104857600,
      "writtenBytes": 104857600,
      "transferredBytes": 209715200,
      "byteWeightedLiveFraction": 1,
      "unweightedLiveFraction": 1,
      "logWriteRatio": null,
      "totalTransferRatio": null
    }
  ]
}
