feat(compress): move sequence leaves to Rust
Move sequence-store byte accounting, chunk derivation, and repcode resolution into the Rust compression module. Move MT raw-sequence buffer conversions into Rust while preserving the existing C adapters and ABI layouts. Test Plan:\n- cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression\n- cargo clippy --manifest-path rust/Cargo.toml\n- cargo clippy --manifest-path rust/Cargo.toml --benches\n- cargo clippy --manifest-path rust/Cargo.toml --tests\n- make -B -C lib -j2 lib\n- make -B -C tests -j2 test-cli-tests
This commit is contained in:
@@ -115,6 +115,25 @@ void ZSTDMT_rust_buffer_pool_release(ZSTDMT_RustBufferPool* pool,
|
||||
ZSTDMT_RustBuffer ZSTDMT_rust_buffer_pool_resize(ZSTDMT_RustBufferPool* pool,
|
||||
ZSTDMT_RustBuffer buffer);
|
||||
|
||||
typedef struct {
|
||||
rawSeq* seq;
|
||||
size_t pos;
|
||||
size_t posInSequence;
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
} ZSTDMT_RustRawSeqStore;
|
||||
|
||||
typedef char ZSTDMT_rust_raw_seq_layout[
|
||||
(sizeof(rawSeq) == 3 * sizeof(U32)) ? 1 : -1];
|
||||
typedef char ZSTDMT_rust_raw_seq_store_layout[
|
||||
(sizeof(ZSTDMT_RustRawSeqStore) == sizeof(RawSeqStore_t)
|
||||
&& offsetof(ZSTDMT_RustRawSeqStore, pos) == offsetof(RawSeqStore_t, pos)
|
||||
&& offsetof(ZSTDMT_RustRawSeqStore, capacity) == offsetof(RawSeqStore_t, capacity))
|
||||
? 1 : -1];
|
||||
|
||||
ZSTDMT_RustRawSeqStore ZSTDMT_rust_bufferToSeq(ZSTDMT_RustBuffer buffer);
|
||||
ZSTDMT_RustBuffer ZSTDMT_rust_seqToBuffer(ZSTDMT_RustRawSeqStore seq);
|
||||
|
||||
unsigned ZSTDMT_rust_computeTargetJobLog(unsigned windowLog, unsigned chainLog,
|
||||
int strategy, int enableLdm);
|
||||
int ZSTDMT_rust_overlapLog(int overlapLog, int strategy);
|
||||
@@ -234,18 +253,29 @@ static size_t ZSTDMT_sizeof_seqPool(ZSTDMT_seqPool* seqPool)
|
||||
|
||||
static RawSeqStore_t bufferToSeq(Buffer buffer)
|
||||
{
|
||||
RawSeqStore_t seq = kNullRawSeqStore;
|
||||
seq.seq = (rawSeq*)buffer.start;
|
||||
seq.capacity = buffer.capacity / sizeof(rawSeq);
|
||||
ZSTDMT_RustRawSeqStore const rustSeq =
|
||||
ZSTDMT_rust_bufferToSeq((ZSTDMT_RustBuffer){ buffer.start, buffer.capacity });
|
||||
RawSeqStore_t seq = {
|
||||
(rawSeq*)rustSeq.seq,
|
||||
rustSeq.pos,
|
||||
rustSeq.posInSequence,
|
||||
rustSeq.size,
|
||||
rustSeq.capacity
|
||||
};
|
||||
return seq;
|
||||
}
|
||||
|
||||
static Buffer seqToBuffer(RawSeqStore_t seq)
|
||||
{
|
||||
Buffer buffer;
|
||||
buffer.start = seq.seq;
|
||||
buffer.capacity = seq.capacity * sizeof(rawSeq);
|
||||
return buffer;
|
||||
ZSTDMT_RustRawSeqStore const rustSeq = {
|
||||
seq.seq,
|
||||
seq.pos,
|
||||
seq.posInSequence,
|
||||
seq.size,
|
||||
seq.capacity
|
||||
};
|
||||
ZSTDMT_RustBuffer const rustBuffer = ZSTDMT_rust_seqToBuffer(rustSeq);
|
||||
return (Buffer){ rustBuffer.start, rustBuffer.capacity };
|
||||
}
|
||||
|
||||
static RawSeqStore_t ZSTDMT_getSeq(ZSTDMT_seqPool* seqPool)
|
||||
|
||||
Reference in New Issue
Block a user