Skip to content

docs(design): zsync hash-layout decision record (compact keys) - #3643

Merged
oferchen merged 1 commit into
masterfrom
docs/zsync-hash-layout-decision-2054
May 5, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/zsync-hash-layout-decision-2054

Conversation

@oferchen

@oferchen oferchen commented May 5, 2026

Copy link
Copy Markdown
Owner

Recommendation

Defer pending #2073 cachegrind data; keep Option A (current FxHashMap) as the default unless the prototype shows >15% L1-data miss reduction or >10% wall-clock speedup on the 100 MB-modified benchmark.

Summary

Adds an ADR for the fourth zsync-inspired matching insertion point: the in-memory layout of the rolling-checksum lookup map in crates/match/src/index/mod.rs. Scopes the keep-or-drop decision for the compact-keys prototype (#2072) and its bench (#2073) without touching code.

Options considered

  • Option A - keep FxHashMap<(u16, u16), Vec<usize>> (today's code).
  • Option B - Vec<(u32, u32)> sorted by rsum_low, binary search.
  • Option C - zsync-style open-addressed table with linear probing (~6 bytes/entry).

The ADR walks each option's footprint, per-hit and per-miss cost, and L1/L2/L3 cache behaviour at 1 K, 100 K, and 1 M block counts, and ties the decision to concrete numeric thresholds from #2073.

Wire-compat invariants - all green

This is a purely in-memory layout decision. Every option preserves byte-identical output against upstream rsync 3.0.9 / 3.1.3 / 3.4.1 in both directions:

  • crates/protocol/tests/golden/ byte goldens stay green.
  • tools/ci/run_interop.sh produces no new entries in tools/ci/known_failures.conf.
  • No new CLI flag in crates/cli/.
  • No crates/protocol change beyond internal API plumbing.
  • Public match::index surface (find_match_bytes, find_match_slices) keeps current signatures.

Risk if dropped

Bithash (#2059), seq-match (#2064), and prune (#2068) are independent and additive; compact keys can be deferred indefinitely without blocking any of the other three. The decision is reversible and gated on benchmark evidence.

Test plan

  • No code changes; docs-only PR.
  • No forbidden strings (verified via grep).
  • No em-dashes.
  • Single file added under docs/design/.
  • Cites specific oc-rsync source lines and zsync 0.6.2 librcksum source files.

Refs #2054.

Add ADR for the fourth zsync-inspired matching insertion point: in-memory
layout of the rolling-checksum lookup map. Records three options (keep
FxHashMap, sorted-vec binary search, open-addressed table), benchmark-
driven decision criteria gated on #2073 cachegrind data, cache-behaviour
reasoning across L1/L2/L3 working sets, and the wire-compat invariants
(zero wire impact under any option). Recommendation: defer pending #2073;
keep Option A as default unless cache-miss gain exceeds 15% or wall-clock
gain exceeds 10% on the 100 MB-modified benchmark.

Refs #2054.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 5, 2026
@oferchen
oferchen merged commit 6624541 into master May 5, 2026
8 checks passed
@oferchen
oferchen deleted the docs/zsync-hash-layout-decision-2054 branch May 5, 2026 09:37
oferchen added a commit that referenced this pull request May 18, 2026
Add ADR for the fourth zsync-inspired matching insertion point: in-memory
layout of the rolling-checksum lookup map. Records three options (keep
FxHashMap, sorted-vec binary search, open-addressed table), benchmark-
driven decision criteria gated on #2073 cachegrind data, cache-behaviour
reasoning across L1/L2/L3 working sets, and the wire-compat invariants
(zero wire impact under any option). Recommendation: defer pending #2073;
keep Option A as default unless cache-miss gain exceeds 15% or wall-clock
gain exceeds 10% on the 100 MB-modified benchmark.

Refs #2054.
oferchen added a commit that referenced this pull request Aug 24, 2026
Add ADR for the fourth zsync-inspired matching insertion point: in-memory
layout of the rolling-checksum lookup map. Records three options (keep
FxHashMap, sorted-vec binary search, open-addressed table), benchmark-
driven decision criteria gated on #2073 cachegrind data, cache-behaviour
reasoning across L1/L2/L3 working sets, and the wire-compat invariants
(zero wire impact under any option). Recommendation: defer pending #2073;
keep Option A as default unless cache-miss gain exceeds 15% or wall-clock
gain exceeds 10% on the 100 MB-modified benchmark.

Refs #2054.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant