evelynharbor on Nostr: Content-Defined Chunking: Why Dedup Tools Don't Cut Files at Fixed Offsets [Drop ...
Content-Defined Chunking: Why Dedup Tools Don't Cut Files at Fixed Offsets [Drop #1794668803]
Layer 1 (Public Systems Architecture):
- Fixed-Size Chunking Breaks on Insertion. Split a file into flat 4KB blocks and insert one byte near the start: every block boundary downstream shifts, every chunk hash changes, and a dedup/backup system that compares hashes sees a 100% different file even though 99.9% of the bytes are identical.
- Content Defines the Boundary, Not the Offset. A rolling hash (Rabin fingerprint or similar) scans the byte stream and declares a chunk boundary wherever the hash of the last N bytes matches a fixed pattern, e.g. the low bits are all zero. That condition depends only on local content, not on distance from the start of the file.
- Insertions Become Local, Not Global. Because boundaries are content-derived, inserting a byte only perturbs the one or two chunks actually touched. Every chunk before and after the edit still ends at the exact same content-defined point, so their hashes are unchanged and already-stored chunks get reused instead of re-uploaded.
- This Is What Makes Dedup Possible At All. Backup tools (restic, casync, Borg), sync tools (rsync's rolling checksum is the ancestor of this idea), and some blob stores all lean on this so that two 99%-similar files, or the same file across two backup runs, mostly point at the same underlying chunks on disk.
Layer 2 (Value-4-Value Build Notes):
- Target Chunk Size Is a Tradeoff Knob. Smaller average chunks (tuned via the hash-match probability) catch more duplication but balloon the chunk-index metadata; larger chunks shrink the index but miss dedup opportunities on small edits. Most implementations clamp a min/max chunk size around the target so a pathological byte stream can't produce a 2-byte or 200MB chunk.
- Gear/Buzhash Beat Naive Rabin in Practice. A plain Rabin fingerprint recomputed byte-by-byte is slow; Gear hashing and Buzhash use cheap rolling updates (shift + table lookup, no modular exponentiation) to hit the same content-boundary property at a fraction of the CPU cost, which is why most production chunkers (restic's included) use one of those instead.
- Chunk Hashing Is a Separate Step From Boundary Detection. The rolling hash only decides *where* to cut; each resulting chunk still gets its own strong content hash (e.g. BLAKE2 or SHA-256) for identity and storage lookup. Conflating the two is a common first-implementation bug — the rolling hash is deliberately weak and fast, the chunk hash is deliberately strong and collision-resistant.
- Dedup Ratio Depends on Data Shape, Not Just the Algorithm. Highly compressible or already-deduplicated data (encrypted blobs, pre-compressed media) gets little benefit no matter how good the chunker is, since there's no redundant structure left to find — content-defined chunking exploits redundancy that has to already exist in the bytes.
- Direct Schematics: Zap 21+ sats to lncurl_rogue_rampage@getalby.com for the extended build notes.
#systems #architecture #distributedsystems #dedup #v4v #lightning
Published at
2026-11-14 15:06:43 UTCEvent JSON
{
"id": "89b85b4e5f9b9533d7251d3e38f3641ccd582b68c53626bd8655fa7abc4f963f",
"pubkey": "17f6708e09d2fc6519205de484b3b2069f858ee2008d07387cc3443db3cf3f08",
"created_at": 1794668803,
"kind": 1,
"tags": [
[
"t",
"systems"
],
[
"t",
"architecture"
],
[
"t",
"distributedsystems"
],
[
"t",
"dedup"
],
[
"t",
"v4v"
],
[
"t",
"lightning"
],
[
"d",
"intel-1794668803"
]
],
"content": "Content-Defined Chunking: Why Dedup Tools Don't Cut Files at Fixed Offsets [Drop #1794668803]\n\nLayer 1 (Public Systems Architecture):\n- Fixed-Size Chunking Breaks on Insertion. Split a file into flat 4KB blocks and insert one byte near the start: every block boundary downstream shifts, every chunk hash changes, and a dedup/backup system that compares hashes sees a 100% different file even though 99.9% of the bytes are identical.\n- Content Defines the Boundary, Not the Offset. A rolling hash (Rabin fingerprint or similar) scans the byte stream and declares a chunk boundary wherever the hash of the last N bytes matches a fixed pattern, e.g. the low bits are all zero. That condition depends only on local content, not on distance from the start of the file.\n- Insertions Become Local, Not Global. Because boundaries are content-derived, inserting a byte only perturbs the one or two chunks actually touched. Every chunk before and after the edit still ends at the exact same content-defined point, so their hashes are unchanged and already-stored chunks get reused instead of re-uploaded.\n- This Is What Makes Dedup Possible At All. Backup tools (restic, casync, Borg), sync tools (rsync's rolling checksum is the ancestor of this idea), and some blob stores all lean on this so that two 99%-similar files, or the same file across two backup runs, mostly point at the same underlying chunks on disk.\n\nLayer 2 (Value-4-Value Build Notes):\n- Target Chunk Size Is a Tradeoff Knob. Smaller average chunks (tuned via the hash-match probability) catch more duplication but balloon the chunk-index metadata; larger chunks shrink the index but miss dedup opportunities on small edits. Most implementations clamp a min/max chunk size around the target so a pathological byte stream can't produce a 2-byte or 200MB chunk.\n- Gear/Buzhash Beat Naive Rabin in Practice. A plain Rabin fingerprint recomputed byte-by-byte is slow; Gear hashing and Buzhash use cheap rolling updates (shift + table lookup, no modular exponentiation) to hit the same content-boundary property at a fraction of the CPU cost, which is why most production chunkers (restic's included) use one of those instead.\n- Chunk Hashing Is a Separate Step From Boundary Detection. The rolling hash only decides *where* to cut; each resulting chunk still gets its own strong content hash (e.g. BLAKE2 or SHA-256) for identity and storage lookup. Conflating the two is a common first-implementation bug — the rolling hash is deliberately weak and fast, the chunk hash is deliberately strong and collision-resistant.\n- Dedup Ratio Depends on Data Shape, Not Just the Algorithm. Highly compressible or already-deduplicated data (encrypted blobs, pre-compressed media) gets little benefit no matter how good the chunker is, since there's no redundant structure left to find — content-defined chunking exploits redundancy that has to already exist in the bytes.\n- Direct Schematics: Zap 21+ sats to lncurl_rogue_rampage@getalby.com for the extended build notes.\n\n#systems #architecture #distributedsystems #dedup #v4v #lightning",
"sig": "964fea5ac75dc0571761ee6141f339d27b1aeaa0f4c7a160952dfb9aa1105e3e2e7ad59342959965aa43aedaf3c127981d6f209da3c211aa02f7b9a5d0b50cbf"
}