interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

branch main Branches Tags History

synapse / docs / G2_CONTENT_DEFINED_CHUNKING.md

94 lines · 7213 bytes Raw Blame History Source

G2: Content-Defined Chunking

ADR 0003 section 9 step G2 (issue #45), design in section 5.9, parameters chosen by experiment X6 (section 6.4). A blob above a threshold is cut into content-defined chunks by a FastCDC-style gear chunker and stored in the segments as chunks, one copy per ChunkDigest. A blob's identity stays its BlobDigest over the whole content (CONTEXT.md), so changing the parameters never changes an identity.

Based on A2 (PR #77, merged) and B1 (PR #81, merged); revision records (B1) still store their blobs whole.

1. Design

2. Acceptance and Tests

Tests in crates/synapse-store/src/g2_tests.rs; expected chunk bytes are computed from the chunker alone.

Acceptance itemTestWhat it shows
Every blob round-trips byte for byte with unchanged BlobDigestg2_every_blob_round_trips_byte_for_byte_with_unchanged_blob_digestSizes 0, 1, T-1, T, T+1, 3 MB random, repetitive, zeros, text; read back after commit, checkpoint, reopen from the index, reopen by replay; manifest equals the chunker's cut, blobs at most T stay whole
Dedup between two revisions follows the X6 ruleg2_dedup_between_two_revisions_follows_the_x6_ruleRevision B stores exactly its chunks not already indexed; an identical revision adds nothing; chunks shared inside one record; a blob of at most T is not cut; same after checkpoint and reopen
Dedup inside a batchg2_dedup_inside_one_batch_counts_earlier_recordsFour revisions in one group-commit batch store each chunk once
Parameters change without changing identityg2_parameters_change_without_changing_identityOFF-then-K1 stores and a store opened with other parameters read everything
Fail closedg2_damaged_chunk_is_refused, g2_manifest_naming_an_unindexed_chunk_is_refused_at_replay, g2_invalid_chunk_parameters_are_refused_at_open, g2_segment_index_v2_round_trips_and_refuses_damageA damaged chunk byte (also with CRC and frame digest repaired) is refused at replay or read; orphan manifests, bad parameters and malformed index v2 are refused
Crashg2_crash_after_chunked_batch_sync_before_index_keeps_every_ackProcess crash after a chunked batch is durable: every acknowledged change survives, the pending one reads back
Old stores readableg2_old_stores_stay_readable, g2_chunking_off_writes_the_a2_formatsA1 fixtures and an A2 segment store written by the A2 code (tests/fixtures/g2-a2, generator in evidence/.../fixture-generator); OFF writes the A2 formats

2.1 Red before green

evidence/g2-content-defined-chunking/red-green/: red-a2-compile.txt (the G2 tests do not build on A2 6431fcf), red-a2-behaviour.txt (on A2, revision B of a 430 KB blob sharing all but about 30 KB with A appends 434,176 log bytes), mutation-M1.txt to mutation-M8.txt (run-mutations.sh: each defect put back makes at least one test fail; green.txt is the clean run):

MutationDefect put backTests that fail
M1No dedup against the chunk index4
M2Checkpoint index drops chunks and manifests6
M3Replay accepts manifests with unindexed chunks1
M4Threshold off by one (T bytes chunked)2
M5Chunked read skips the BlobDigest check1
M6Earlier records of a batch do not count as indexed1
M7Replay forgets manifests5
M8WAL decode skips the chunk digest check1

3. Experiment X6 and Measurement

Rule: evidence/g2-content-defined-chunking/x6/RULE.md, committed alone before any run. Results and decision: x6/RESULTS.md. Real AIEN histories (1,037 changes, 24,093 revisions, 433.8 MB); eight configurations, three repetitions, order rotated. K1 wins (the only eligible candidate): 20.7 % fewer log bytes than no chunking (329,252,864 vs 415,395,840), 1.095 times the seconds per accepted change (2.133 ms vs 1.947 ms; the limit was 1.10, a thin margin on a shared host), 1.068 times the seconds per read. Against the A2 flush bound of 1.006 ms, K1 reaches 0.471 of the bound at one agent (no chunking: 0.516). Joules per change from the SoC package meter are inside the noise above idle (RESULTS.md).

4. Deviations from ADR Section 5.9

5. Limits