# Repeated-byte FastCDC experiment

Hesela, 20 October 2026. Synthetic mechanism experiment, not a benchmark.

## Reproduce

Use CPython 3.12.3 for exact environment-metadata comparison:

```sh
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/python -B experiment.py --check results.json
.venv/bin/python -B -m unittest -v test_experiment.py
```

To regenerate, use --output results.json. Only generatedAt is excluded by --check.
The harness checks package version and SHA-256 of both imported implementation
modules before executing the unmodified pure-Python API (not its platform default).
The dependencies are MIT licensed. No third-party library code is vendored.

## Population and method

All 256 possible byte values are tested, each repeated 131073 times in its own
input stream. Minimum/requested-average/maximum are 2048/8192/65536 bytes.
Each chunk is retained, including EOF tails; concatenating its actual returned
bytes must exactly reconstruct the input.

The pinned implementation uses p_next = floor(p/2) + g, starting at zero.
For constant g > 0, p_t = 2*g - ceil(2*g / 2**t), reaching the odd state
2*g - 1. This is a derivation from that recurrence, not a claim that all Gear
variants use it. The 2016 FastCDC paper instead describes a left-shift variant.
Tests compare the closed form against iterative updates for the entire Gear table.

A predicate match in the early phase must occur during the transient: both masks
include bit zero, so the stable odd state fails both. The formula enumerates only
that short transient, independently predicting the first cut and comparing it
against the library's full input scan. The normalization transition is 5120 bytes.
Every fixture resets its state at each chunk. Terminal chunks remain in results.

255 inputs produce 65536,65536,1 bytes. Repeated byte 0x5D produces 63 chunks
of 2070 bytes and a 663-byte tail: its 22nd early update passes the mask.

This is exhaustive over a small constructed input class, not a random sample of
storage workloads. No confidence interval, speedup, deduplication ratio, compression
ratio, hardware claim or general claim about all FastCDC variants follows.

Sources:
- Xia et al., USENIX ATC 2016, sections 3-4:
  https://www.usenix.org/system/files/conference/atc16/atc16-paper-xia.pdf
- fastcdc-py v1.7.0, cdc_offset/chunk_generator and Gear table:
  https://github.com/iscc/fastcdc-py/blob/v1.7.0/fastcdc/fastcdc_py.py
- Muthitacharoen, Chen and Mazieres, SOSP 2001, section 3.1.2:
  https://pdos.csail.mit.edu/papers/lbfs:sosp01/lbfs.pdf
