Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
85c1080
perf(encoding): #111 Phase 7c — split dfast hash table sizing to dono…
polaz May 16, 2026
eab4d73
perf(encoding): #111 Phase 7c — port donor single-slot storage + spar…
polaz May 16, 2026
9bb724e
perf(encoding): #111 Phase 7c step 3 — drop dfast window-Vec byte dup…
polaz May 16, 2026
e96bce8
perf(encoding): preallocate compress_to_vec output, add compress_slic…
polaz May 16, 2026
87e2eef
perf(encoding): cap compress_slice_to_vec initial capacity at one out…
polaz May 16, 2026
078e621
perf(dfast): tighten insert_positions inner loop with hoisted invariants
polaz May 16, 2026
5372ae9
perf(dfast): peek repcode at ip+1 to match donor exactly
polaz May 16, 2026
c6eb5a8
perf(dfast): lower DFAST_MIN_MATCH_LEN from 6 to 5 to match donor mls
polaz May 16, 2026
67a4785
perf(dfast): switch hash to donor scalar mul, drop CRC32d kernel disp…
polaz May 16, 2026
233603f
perf(dfast): inline(always) on best_match → hash_candidate → probe_sl…
polaz May 16, 2026
70f966b
perf(build): enable fat LTO and codegen-units=1 for release/bench
polaz May 16, 2026
8e72d58
perf(dfast): grow skip-step by scan distance to match donor
polaz May 16, 2026
78f51da
perf(dfast): rewrite start_matching_fast_loop in donor outer/inner shape
polaz May 16, 2026
1e6d5dd
perf(dfast): inline rep1-only peek at ip+1 (donor parity, drop rep2/r…
polaz May 16, 2026
b2b4d48
chore: ignore local helper docs in .local/
polaz May 16, 2026
079615c
perf(encoding): scale initial all_blocks capacity by source-size hint
polaz May 16, 2026
ef906f7
fix(dfast): tighten fast_loop guards to HASH_READ_SIZE to stop OOB load
polaz May 16, 2026
bac47a6
chore: rescope LTO to bench, fix stale docs, sync bench API call
polaz May 16, 2026
87a62e3
fix(dfast): rebase before fast-loop slot pack + compact on trim
polaz May 16, 2026
36d5daa
fix(dfast): carry tail seed cursor + simplify committed + scrub dead …
polaz May 16, 2026
1121c5e
fix: empty-block guard, compress_bound saturating add, gitignore pattern
polaz May 17, 2026
4a5e72d
docs(dfast): correct collapse-pair, drop tracked interop crash, expec…
polaz May 17, 2026
6aa6576
fix(dfast): free dead prefix on trim, guard ensure_room_for, hoist he…
polaz May 17, 2026
ecd2bfd
fix(dfast): rep1 floor=4, probe gate width, empty-block guards
polaz May 17, 2026
8a6df9f
refactor(dfast): drop history_start alias + clarify fuzz test signal
polaz May 17, 2026
900f211
refactor(dfast): inner-loop exit enum + API symmetry + doc cleanup
polaz May 17, 2026
f928ef4
perf(fse): cache predefined LL/ML/OF default tables in AtomicPtr
polaz May 17, 2026
f9d36b1
fix(dfast): probe last hashable position + enforce short-hash floor
polaz May 17, 2026
0cbb300
fix(dfast,fse): drop unused trim arg, harden FSE cache slot routing
polaz May 17, 2026
0338876
perf(fse): return &'static FSETable from cache + dfast cleanup
polaz May 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ benchmark-delta.md
benchmark-relative.json
fuzz/corpus
zstd/fuzz/corpus
# Fresh fuzz crashes from local `cargo fuzz run` sessions are CI/local
# scratch — they live in the runner. Pre-existing tracked artifacts
# under `decode/`, `fse/`, `huff0/` keep working because git tracks
# them by index regardless of this pattern; new untracked crashes
# stop polluting `git status`.
zstd/fuzz/artifacts/**
.idea
/=
AGENTS.md
.claude/
.local/
**/__pycache__/
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[workspace]
resolver = "3"
members = ["zstd", "cli"]

# Bench profile inherits from release but overrides LTO/codegen-units so
# the perf measurement reflects full cross-crate inlining. We deliberately
# scope this to `[profile.bench]` instead of `[profile.release]`: the
# release profile is shared by the `cli` binary and every downstream
# consumer of this workspace, and fat LTO + codegen-units = 1 multiplies
# release build times ~5× and significantly increases peak compile RAM.
# Bench builds run on CI with the wall clock budget for it; everyday
# `cargo build --release` (and downstream consumers) should not pay that
# cost without explicitly opting in.
[profile.bench]
lto = "fat"
codegen-units = 1
10 changes: 6 additions & 4 deletions zstd/benches/compare_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn bench_compress(c: &mut Criterion) {
for scenario in benchmark_scenarios_cached().iter() {
for level in supported_levels_filtered() {
if emit_reports {
let rust_compressed = structured_zstd::encoding::compress_to_vec(
let rust_compressed = structured_zstd::encoding::compress_slice_to_vec(
&scenario.bytes[..],
level.rust_level,
);
Comment thread
polaz marked this conversation as resolved.
Expand All @@ -230,7 +230,7 @@ fn bench_compress(c: &mut Criterion) {

group.bench_function("pure_rust", |b| {
b.iter(|| {
black_box(structured_zstd::encoding::compress_to_vec(
black_box(structured_zstd::encoding::compress_slice_to_vec(
&scenario.bytes[..],
level.rust_level,
))
Expand All @@ -250,8 +250,10 @@ fn bench_decompress(c: &mut Criterion) {
let emit_reports = emit_reports_enabled();
for scenario in benchmark_scenarios_cached().iter() {
for level in supported_levels_filtered() {
let rust_compressed =
structured_zstd::encoding::compress_to_vec(&scenario.bytes[..], level.rust_level);
let rust_compressed = structured_zstd::encoding::compress_slice_to_vec(
&scenario.bytes[..],
level.rust_level,
);
let ffi_compressed = ffi_encode_to_vec(&scenario.bytes[..], level.ffi_level);
let expected_len = scenario.len();
bench_decompress_source(
Expand Down
5 changes: 4 additions & 1 deletion zstd/benches/compare_ffi_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ fn main() {
for level in supported_levels_filtered() {
// Compress
let (rust_compressed, rust_peak) = measure_peak(|| {
structured_zstd::encoding::compress_to_vec(&scenario.bytes[..], level.rust_level)
structured_zstd::encoding::compress_slice_to_vec(
&scenario.bytes[..],
level.rust_level,
)
});
let (ffi_compressed, ffi_peak) =
measure_peak(|| ffi_encode(&scenario.bytes[..], level.ffi_level));
Expand Down
57 changes: 30 additions & 27 deletions zstd/src/encoding/blocks/compressed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,19 @@ fn encode_block_parts_with_sequence_scratch<M: Matcher>(
// Choose the tables
let ll_mode = choose_table(
state.fse_tables.ll_previous.as_ref(),
&state.fse_tables.ll_default,
state.fse_tables.ll_default,
sequences.iter().map(|seq| encode_literal_length(seq.ll).0),
9,
);
let ml_mode = choose_table(
state.fse_tables.ml_previous.as_ref(),
&state.fse_tables.ml_default,
state.fse_tables.ml_default,
sequences.iter().map(|seq| encode_match_len(seq.ml).0),
9,
);
let of_mode = choose_table(
state.fse_tables.of_previous.as_ref(),
&state.fse_tables.of_default,
state.fse_tables.of_default,
sequences.iter().map(|seq| encode_offset(seq.of).0),
8,
);
Expand Down Expand Up @@ -540,26 +540,26 @@ fn estimate_sequences_section_bytes(
// internally, identical decision path.
let ll_mode = choose_table(
fse_tables.ll_previous.as_ref(),
&fse_tables.ll_default,
fse_tables.ll_default,
sequences.iter().map(|seq| encode_literal_length(seq.ll).0),
9,
);
let ml_mode = choose_table(
fse_tables.ml_previous.as_ref(),
&fse_tables.ml_default,
fse_tables.ml_default,
sequences.iter().map(|seq| encode_match_len(seq.ml).0),
9,
);
let of_mode = choose_table(
fse_tables.of_previous.as_ref(),
&fse_tables.of_default,
fse_tables.of_default,
sequences.iter().map(|seq| encode_offset(seq.of).0),
8,
);

let ll_bits_chosen = fse_section_bits_for_mode(&ll_mode, ll_counts, &fse_tables.ll_default);
let ml_bits_chosen = fse_section_bits_for_mode(&ml_mode, ml_counts, &fse_tables.ml_default);
let of_bits_chosen = fse_section_bits_for_mode(&of_mode, of_counts, &fse_tables.of_default);
let ll_bits_chosen = fse_section_bits_for_mode(&ll_mode, ll_counts, fse_tables.ll_default);
let ml_bits_chosen = fse_section_bits_for_mode(&ml_mode, ml_counts, fse_tables.ml_default);
let of_bits_chosen = fse_section_bits_for_mode(&of_mode, of_counts, fse_tables.of_default);

let ll_table_desc_bytes = mode_table_description_bytes(&ll_mode);
let ml_table_desc_bytes = mode_table_description_bytes(&ml_mode);
Expand Down Expand Up @@ -822,12 +822,15 @@ fn encode_raw_sequences_into(
}

fn clone_fse_tables(fse_tables: &FseTables) -> FseTables {
// `*_default` fields are `&'static FSETable` (pointer-sized
// copies, cache-backed); only the `*_previous` per-frame tables
// need a deep clone.
FseTables {
ll_default: fse_tables.ll_default.clone(),
ll_default: fse_tables.ll_default,
ll_previous: fse_tables.ll_previous.clone(),
ml_default: fse_tables.ml_default.clone(),
ml_default: fse_tables.ml_default,
ml_previous: fse_tables.ml_previous.clone(),
of_default: fse_tables.of_default.clone(),
of_default: fse_tables.of_default,
of_previous: fse_tables.of_previous.clone(),
}
}
Expand Down Expand Up @@ -1252,9 +1255,9 @@ fn encode_sequences(
let (ll_code, ll_add_bits, ll_num_bits) = encode_literal_length(sequence.ll);
let (of_code, of_add_bits, of_num_bits) = encode_offset(sequence.of);
let (ml_code, ml_add_bits, ml_num_bits) = encode_match_len(sequence.ml);
let ll_table = mode_table(ll_mode, &defaults.ll_default);
let ml_table = mode_table(ml_mode, &defaults.ml_default);
let of_table = mode_table(of_mode, &defaults.of_default);
let ll_table = mode_table(ll_mode, defaults.ll_default);
let ml_table = mode_table(ml_mode, defaults.ml_default);
let of_table = mode_table(of_mode, defaults.of_default);
let mut ll_state = ll_table.map(|table| table.start_state(ll_code));
let mut ml_state = ml_table.map(|table| table.start_state(ml_code));
let mut of_state = of_table.map(|table| table.start_state(of_code));
Expand Down Expand Up @@ -1707,34 +1710,34 @@ mod tests {
);

assert!(tables_match(
previous_table(fse_tables.ll_previous.as_ref(), &fse_tables.ll_default).unwrap(),
&fse_tables.ll_default
previous_table(fse_tables.ll_previous.as_ref(), fse_tables.ll_default).unwrap(),
fse_tables.ll_default
));
assert!(tables_match(
previous_table(fse_tables.ml_previous.as_ref(), &fse_tables.ml_default).unwrap(),
&fse_tables.ml_default
previous_table(fse_tables.ml_previous.as_ref(), fse_tables.ml_default).unwrap(),
fse_tables.ml_default
));
assert!(tables_match(
previous_table(fse_tables.of_previous.as_ref(), &fse_tables.of_default).unwrap(),
&fse_tables.of_default
previous_table(fse_tables.of_previous.as_ref(), fse_tables.of_default).unwrap(),
fse_tables.of_default
));

let sample_codes = [0u8, 1u8];
let ll_repeat = choose_table(
fse_tables.ll_previous.as_ref(),
&fse_tables.ll_default,
fse_tables.ll_default,
sample_codes.iter().copied(),
9,
);
let ml_repeat = choose_table(
fse_tables.ml_previous.as_ref(),
&fse_tables.ml_default,
fse_tables.ml_default,
sample_codes.iter().copied(),
9,
);
let of_repeat = choose_table(
fse_tables.of_previous.as_ref(),
&fse_tables.of_default,
fse_tables.of_default,
sample_codes.iter().copied(),
8,
);
Expand All @@ -1751,7 +1754,7 @@ mod tests {
fse_tables.ll_previous = Some(PreviousFseTable::Custom(Box::new(custom)));

let before = core::ptr::from_ref(
previous_table(fse_tables.ll_previous.as_ref(), &fse_tables.ll_default).unwrap(),
previous_table(fse_tables.ll_previous.as_ref(), fse_tables.ll_default).unwrap(),
);

remember_last_used_tables(
Expand All @@ -1762,7 +1765,7 @@ mod tests {
);

let after = core::ptr::from_ref(
previous_table(fse_tables.ll_previous.as_ref(), &fse_tables.ll_default).unwrap(),
previous_table(fse_tables.ll_previous.as_ref(), fse_tables.ll_default).unwrap(),
);

assert_eq!(before, after);
Expand All @@ -1777,7 +1780,7 @@ mod tests {
let fse_tables = FseTables::new();
let mode = choose_table(
None,
&fse_tables.ll_default,
fse_tables.ll_default,
core::iter::repeat_n(0u8, 32),
9,
);
Expand Down
Loading
Loading