Skip to content

test(matching): add wire-byte parity tests for zsync optimizations (ZSO-5) - #4627

Merged
oferchen merged 1 commit into
masterfrom
test/matching-zsync-wire-byte-parity-zso5
May 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/matching-zsync-wire-byte-parity-zso5

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds crates/matching/tests/zsync_wire_parity.rs, the ZSO-5 (task perf(io_uring): add IORING_OP_RECV/IORING_OP_SEND for socket I/O #2513) regression suite for the zsync-inspired matching optimizations.
  • For each of ZSO-1..4, constructs a basis + source pair designed to hit that optimization's code path, runs generate_delta, serialises the resulting DeltaScript through the production wire-format encoder (protocol::wire::write_token_stream), and pins the byte stream against determinism + round-trip reconstruction.
  • Complements the protocol-layer golden tests at crates/protocol/tests/golden_protocol_v28_mplex_delta_stats.rs (which pin the token framing format itself but do not synthesize ZSO-specific basis fixtures).

ZSO coverage

ZSO Task Status This PR
ZSO-1 #2510 shipped in PR #3737 active test
ZSO-2 #2510 in flight on PR #4624 active test (see note)
ZSO-3 #2511 pending #[ignore] stub
ZSO-4 #2512 pending #[ignore] stub

ZSO-2 note: the active seq_match_optimization_preserves_wire_bytes test passes today because extend_run plus the existing script-level coalescing already produces the single-fat-copy shape the test pins. When PR #4624 swaps the probe path onto try_next_match_slices, the same fixed-seed input must continue to produce byte-identical wire output (different probe, identical emitted tokens). The dependency is documented inline in the test rustdoc.

Stubs for ZSO-3 / ZSO-4 are structured so the only enablement step required when those land is dropping #[ignore] and swapping the placeholder corpus for the duplicate-heavy / small-basis fixtures documented in the test rustdoc.

Why pin wire bytes here?

The protocol golden tests cover wire-byte correctness at the protocol layer (multiplex headers, token framing, NDX encoding). They do not synthesize the basis + source pairs that exercise each ZSO optimization path, so a future regression in crates/matching/src/ that changed token shape but preserved frame-level validity would slip past them. This file is the complement.

Implementation notes

  • No production code changes; no new dependencies. Determinism uses a small in-test LCG (matches the existing pattern used elsewhere under crates/matching/tests/).
  • Corpora are bounded at <= 64 KB to keep the suite under cargo nextest timeouts.
  • The script_to_ops helper mirrors transfer::generator::delta::script_to_wire_delta without pulling the transfer crate as a dev-dep.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings clean
  • cargo nextest run -p matching --all-features -> 321 passed, 5 skipped (includes 2 ZSO stub tests gated by #[ignore])
  • cargo nextest run -p matching --all-features -E 'binary(zsync_wire_parity)' --run-ignored all -> 5 passed (3 active + 2 ignored stubs execute without panicking)
  • cargo nextest run -p protocol --all-features -E 'test(golden)' -> 407 passed (wire-format goldens untouched)

@github-actions github-actions Bot added the test label May 21, 2026
…SO-5)

Adds the ZSO-5 (task #2513) regression suite at
crates/matching/tests/zsync_wire_parity.rs. For each ZSO-1..4
optimization, constructs a basis + source pair designed to exercise
that optimization's code path, runs generate_delta, serialises the
DeltaScript through the production wire-format encoder
(protocol::wire::write_token_stream), and pins the resulting bytes
against (a) determinism across repeated runs and (b) round-trip
reconstruction of the source via apply_delta.

Active tests:
- bithash_optimization_preserves_wire_bytes (ZSO-1, task #2510, shipped
  in PR #3737) - 16 KiB random basis + disjoint random source so every
  rolling probe walks the bithash reject path. Asserts all-literal
  script and deterministic wire bytes.
- seq_match_optimization_preserves_wire_bytes (ZSO-2, task #2510,
  landing on PR #4624) - 84-block basis used as its own source so
  every adjacent-block hint fires. Asserts single fat Copy token and
  deterministic wire bytes. Test was authored to remain green on
  master (extend_run + script-level coalescing already produce the
  pinned shape) and stays green when PR #4624 swaps the probe path.
- all_active_zso_fixtures_are_deterministic - cross-cutting check that
  signals "matching pipeline became non-deterministic" as a single
  failure.

Stub tests (#[ignore]):
- hash_chain_prune_preserves_wire_bytes (ZSO-3, task #2511)
- compact_rolling_key_preserves_wire_bytes (ZSO-4, task #2512)

The stubs are structured so the only step required when those
optimizations land is to drop #[ignore] and swap the placeholder
basis/source for the duplicate-heavy / small-basis corpora documented
in the test rustdoc.

Complements the protocol-layer golden tests at
crates/protocol/tests/golden_protocol_v28_mplex_delta_stats.rs which
pin the token frame format but do not synthesize ZSO-specific basis
fixtures.

No production code changes. No new dependencies (uses a small in-test
LCG to keep the corpus deterministic). All 321 matching tests pass;
407 protocol golden tests pass.
@oferchen
oferchen force-pushed the test/matching-zsync-wire-byte-parity-zso5 branch from dc5dd5c to ceabd86 Compare May 21, 2026 00:48
@oferchen
oferchen merged commit e4477a4 into master May 21, 2026
55 checks passed
@oferchen
oferchen deleted the test/matching-zsync-wire-byte-parity-zso5 branch May 21, 2026 02:56
oferchen added a commit that referenced this pull request Aug 24, 2026
…SO-5) (#4627)

Adds the ZSO-5 (task #2513) regression suite at
crates/matching/tests/zsync_wire_parity.rs. For each ZSO-1..4
optimization, constructs a basis + source pair designed to exercise
that optimization's code path, runs generate_delta, serialises the
DeltaScript through the production wire-format encoder
(protocol::wire::write_token_stream), and pins the resulting bytes
against (a) determinism across repeated runs and (b) round-trip
reconstruction of the source via apply_delta.

Active tests:
- bithash_optimization_preserves_wire_bytes (ZSO-1, task #2510, shipped
  in PR #3737) - 16 KiB random basis + disjoint random source so every
  rolling probe walks the bithash reject path. Asserts all-literal
  script and deterministic wire bytes.
- seq_match_optimization_preserves_wire_bytes (ZSO-2, task #2510,
  landing on PR #4624) - 84-block basis used as its own source so
  every adjacent-block hint fires. Asserts single fat Copy token and
  deterministic wire bytes. Test was authored to remain green on
  master (extend_run + script-level coalescing already produce the
  pinned shape) and stays green when PR #4624 swaps the probe path.
- all_active_zso_fixtures_are_deterministic - cross-cutting check that
  signals "matching pipeline became non-deterministic" as a single
  failure.

Stub tests (#[ignore]):
- hash_chain_prune_preserves_wire_bytes (ZSO-3, task #2511)
- compact_rolling_key_preserves_wire_bytes (ZSO-4, task #2512)

The stubs are structured so the only step required when those
optimizations land is to drop #[ignore] and swap the placeholder
basis/source for the duplicate-heavy / small-basis corpora documented
in the test rustdoc.

Complements the protocol-layer golden tests at
crates/protocol/tests/golden_protocol_v28_mplex_delta_stats.rs which
pin the token frame format but do not synthesize ZSO-specific basis
fixtures.

No production code changes. No new dependencies (uses a small in-test
LCG to keep the corpus deterministic). All 321 matching tests pass;
407 protocol golden tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant