feat(ldm): move sequence-store emission into Rust

Remove the LDM-specific C sequence-store callback and reuse the existing Rust
sequence-store leaf from the fast matcher through a crate-local opaque wrapper.
The LDM C shim now retains only private match-state extraction and compressor
dispatch, with explicit SeqDef and SeqStore_t layout checks protecting the
cross-module pointer contract. The Rust boundary documentation now reflects
that sequence-store encoding is Rust-owned.

Test Plan:
- ulimit -v 41943040 && cargo fmt --manifest-path rust/Cargo.toml && git diff --check
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml zstd_ldm::tests --lib (7 passed)
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml store_seq_preserves_literal --lib (1 passed)
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --lib (683 passed)
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- ulimit -v 41943040 && make -B -C programs -j1 zstd (passed; existing fileio const-cast warnings)
- ulimit -v 41943040 && make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s (84 tests and both short fuzz rounds passed; existing zstreamtest warning)
This commit is contained in:
2026-07-19 18:27:52 +02:00
parent db8c58ac97
commit d38c1e2a62
4 changed files with 121 additions and 32 deletions
+6 -4
View File
@@ -44,9 +44,10 @@ zstd ABI:
and the outer block-dispatch decision. `zstd_compress` also owns ordinary
sequence-block entropy emission, sequence collection, the legacy RLE
compatibility gate, and sequence-store construction; C supplies only the
private matchfinder, LDM, external-sequence-producer, and state-preparation
callbacks. Rust also owns the frame-chunk block loop, including block
sizing, target/split/internal dispatch, output accounting, and frame-state
private matchfinder, LDM block-preparation/consumption, external-sequence-
producer, and state-preparation callbacks. Rust also owns the frame-chunk
block loop, including block sizing, target/split/internal dispatch, output
accounting, and frame-state
updates; C supplies the private block-compression callbacks. Rust also
owns the single-threaded buffered/stable stream state machine, including
direct versus buffered output, pending-output draining, and frame reset
@@ -78,7 +79,8 @@ zstd ABI:
`zstd_opt` owns the dynamic-programming price model, optimal parse, and
sequence emission.
- `zstd_ldm` implements long-distance-match parameter selection, table
maintenance, sequence generation, and sequence consumption.
maintenance, sequence generation, sequence consumption, and sequence-store
encoding.
- Dictionary building
- `divsufsort` constructs the suffix array that drives the legacy `ZDICT`
trainer (`ZDICT_trainFromBuffer_legacy`); `dict_builder_zdict`,