Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ rust-version = "1.88"
exclude = [".github/"]

[workspace]
members = ["systest", "xz", "xz-sys", "perf-probe"]
members = ["systest", "xz-core", "xz-sys", "perf-probe"]

[dependencies]
xz = { path = "xz", optional = true }
xz-core = { path = "xz-core", optional = true }
xz-sys = { path = "xz-sys", optional = true }
liblzma-sys = { path = "liblzma-sys", version = "0.4.5", optional = true, default-features = false }
num_cpus = { version = "1.16.0", optional = true }
Expand Down Expand Up @@ -48,8 +48,8 @@ liblzma-sys = { path = "liblzma-sys" }
wasm-bindgen-test = "0.3"

[features]
default = ["xz"]
xz = ["dep:xz"]
default = ["xz-core"]
xz-core = ["dep:xz-core"]
xz-sys = ["dep:xz-sys"]
liblzma-sys = ["dep:liblzma-sys"]
static = ["liblzma-sys?/static"]
Expand Down
16 changes: 8 additions & 8 deletions benches/backend_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ use std::ptr;
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};

#[cfg(any(
all(feature = "xz", feature = "xz-sys"),
all(feature = "xz", feature = "liblzma-sys"),
all(feature = "xz-core", feature = "xz-sys"),
all(feature = "xz-core", feature = "liblzma-sys"),
all(feature = "xz-sys", feature = "liblzma-sys"),
))]
compile_error!("backend_comparison bench must be built with exactly one backend feature");
#[cfg(not(any(feature = "xz", feature = "xz-sys", feature = "liblzma-sys")))]
compile_error!("backend_comparison bench requires `xz`, `xz-sys`, or `liblzma-sys`");
#[cfg(not(any(feature = "xz-core", feature = "xz-sys", feature = "liblzma-sys")))]
compile_error!("backend_comparison bench requires `xz-core`, `xz-sys`, or `liblzma-sys`");

#[cfg(feature = "liblzma-sys")]
use liblzma_sys::{
lzma_crc32, lzma_crc64, lzma_easy_buffer_encode, lzma_stream_buffer_bound,
lzma_stream_buffer_decode, LZMA_CHECK_CRC64, LZMA_OK,
};
#[cfg(feature = "xz")]
use xz::{
#[cfg(feature = "xz-core")]
use xz_core::{
check::{crc32_fast::lzma_crc32, crc64_fast::lzma_crc64},
common::{
easy_buffer_encoder::lzma_easy_buffer_encode,
Expand All @@ -34,8 +34,8 @@ use xz_sys::{
lzma_stream_buffer_decode, LZMA_CHECK_CRC64, LZMA_OK,
};

#[cfg(feature = "xz")]
const BACKEND_NAME: &str = "xz";
#[cfg(feature = "xz-core")]
const BACKEND_NAME: &str = "xz-core";
#[cfg(feature = "liblzma-sys")]
const BACKEND_NAME: &str = "liblzma-sys";
#[cfg(feature = "xz-sys")]
Expand Down
16 changes: 8 additions & 8 deletions docs/performance-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Important: the C and Rust sys backends must never be linked into the same proces

The root crate now has three backend modes:

- `xz`: direct Rust ABI calls into the pure Rust port
- `xz-core`: direct Rust ABI calls into the pure Rust port
- `xz-sys`: C ABI calls into the pure Rust port through the `xz-sys` shell
- `liblzma-sys`: C ABI calls into vendored C `liblzma`

Expand All @@ -28,7 +28,7 @@ cargo test --test sys_equivalence

## 2. Compare the full test suite

Use `hyperfine` to compare end-to-end wall clock time of the deterministic root test bundle (`xz` vs C) and `systest` with isolated target directories per backend:
Use `hyperfine` to compare end-to-end wall clock time of the deterministic root test bundle (`xz-core` vs C) and `systest` with isolated target directories per backend:

```bash
scripts/compare_backends.sh --runs 10 --warmup 2
Expand Down Expand Up @@ -58,7 +58,7 @@ The root bundle intentionally skips QuickCheck-based unit tests because they gen

## 3. Compare focused workloads

Use `perf-probe`, a small standalone binary crate that links exactly one backend at a time. `scripts/compare_workloads.sh` compares all three backends in separate processes: direct `xz`, `xz-sys`, and vendored C `liblzma-sys`.
Use `perf-probe`, a small standalone binary crate that links exactly one backend at a time. `scripts/compare_workloads.sh` compares all three backends in separate processes: direct `xz-core`, `xz-sys`, and vendored C `liblzma-sys`.

Examples:

Expand Down Expand Up @@ -124,9 +124,9 @@ Use `--name-pattern <substring>` to isolate a file family inside the XZ corpus w
Examples:

```bash
scripts/profile_backend.sh xz decode --size 1048576 --iters 800 --warmup 80
scripts/profile_backend.sh xz size --input-kind random --size 1048576 --iters 800 --warmup 80
scripts/profile_backend.sh xz encode --input-kind random --size 8388608 --iters 150 --warmup 20
scripts/profile_backend.sh xz-core decode --size 1048576 --iters 800 --warmup 80
scripts/profile_backend.sh xz-core size --input-kind random --size 1048576 --iters 800 --warmup 80
scripts/profile_backend.sh xz-core encode --input-kind random --size 8388608 --iters 150 --warmup 20
scripts/profile_backend.sh c crc64 --size 16777216 --iters 400
```

Expand All @@ -151,8 +151,8 @@ On macOS the script prefers `samply`; on Linux it falls back to `perf`; otherwis
After a profile points to a hot Rust function, inspect its optimized output:

```bash
scripts/inspect_codegen.sh xz::lzma::lzma_encoder::lzma_encode --package xz
scripts/inspect_codegen.sh xz::check::crc64_fast::lzma_crc64 --package xz --format llvm
scripts/inspect_codegen.sh xz_core::lzma::lzma_encoder::lzma_encode --package xz-core
scripts/inspect_codegen.sh xz_core::check::crc64_fast::lzma_crc64 --package xz-core --format llvm
```

This uses `cargo-asm` and builds under `target/codegen` by default.
Expand Down
4 changes: 2 additions & 2 deletions examples/bufread_trailing_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::time::{Duration, Instant};

use liblzma::bufread;

#[cfg(feature = "xz")]
const BACKEND_NAME: &str = "xz";
#[cfg(feature = "xz-core")]
const BACKEND_NAME: &str = "xz-core";
#[cfg(feature = "xz-sys")]
const BACKEND_NAME: &str = "xz-sys";
#[cfg(feature = "liblzma-sys")]
Expand Down
4 changes: 2 additions & 2 deletions examples/qc_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::time::{Duration, Instant};
use liblzma::read;
use liblzma::write;

#[cfg(feature = "xz")]
const BACKEND_NAME: &str = "xz";
#[cfg(feature = "xz-core")]
const BACKEND_NAME: &str = "xz-core";
#[cfg(feature = "xz-sys")]
const BACKEND_NAME: &str = "xz-sys";
#[cfg(feature = "liblzma-sys")]
Expand Down
4 changes: 2 additions & 2 deletions examples/standard_files_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use liblzma::read;
use liblzma::stream;
use liblzma::write;

#[cfg(feature = "xz")]
const BACKEND_NAME: &str = "xz";
#[cfg(feature = "xz-core")]
const BACKEND_NAME: &str = "xz-core";
#[cfg(feature = "xz-sys")]
const BACKEND_NAME: &str = "xz-sys";
#[cfg(feature = "liblzma-sys")]
Expand Down
4 changes: 2 additions & 2 deletions perf-probe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ publish = false

[features]
default = []
xz = ["dep:xz"]
xz-core = ["dep:xz-core"]
xz-sys = ["dep:xz-sys"]
liblzma-sys = ["dep:liblzma-sys"]

[dependencies]
liblzma-sys = { path = "../liblzma-sys", optional = true }
xz = { path = "../xz", optional = true }
xz-core = { path = "../xz-core", optional = true }
xz-sys = { path = "../xz-sys", optional = true }
30 changes: 15 additions & 15 deletions perf-probe/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![cfg(not(target_family = "wasm"))]

#[cfg(any(
all(feature = "xz", feature = "xz-sys"),
all(feature = "xz", feature = "liblzma-sys"),
all(feature = "xz-core", feature = "xz-sys"),
all(feature = "xz-core", feature = "liblzma-sys"),
all(feature = "xz-sys", feature = "liblzma-sys"),
))]
compile_error!("Enable exactly one backend feature: xz, xz-sys, or liblzma-sys");
#[cfg(not(any(feature = "xz", feature = "xz-sys", feature = "liblzma-sys")))]
compile_error!("Enable one backend feature: xz, xz-sys, or liblzma-sys");
compile_error!("Enable exactly one backend feature: xz-core, xz-sys, or liblzma-sys");
#[cfg(not(any(feature = "xz-core", feature = "xz-sys", feature = "liblzma-sys")))]
compile_error!("Enable one backend feature: xz-core, xz-sys, or liblzma-sys");

use std::env;
use std::fs;
Expand All @@ -23,19 +23,19 @@ use liblzma_sys::{
lzma_index_uncompressed_size, lzma_stream_buffer_bound, lzma_stream_buffer_decode,
lzma_stream_flags as BackendStreamFlags, lzma_stream_footer_decode,
};
#[cfg(feature = "xz")]
use xz::check::{crc32_fast::lzma_crc32, crc64_fast::lzma_crc64};
#[cfg(feature = "xz")]
use xz::common::{
#[cfg(feature = "xz-core")]
use xz_core::check::{crc32_fast::lzma_crc32, crc64_fast::lzma_crc64};
#[cfg(feature = "xz-core")]
use xz_core::common::{
easy_buffer_encoder::lzma_easy_buffer_encode,
index::{lzma_index_end, lzma_index_uncompressed_size},
index_decoder::lzma_index_buffer_decode,
stream_buffer_decoder::lzma_stream_buffer_decode,
stream_buffer_encoder::lzma_stream_buffer_bound,
stream_flags_decoder::lzma_stream_footer_decode,
};
#[cfg(feature = "xz")]
use xz::types::{
#[cfg(feature = "xz-core")]
use xz_core::types::{
LZMA_CHECK_CRC64, LZMA_OK, LZMA_STREAM_HEADER_SIZE, lzma_index as BackendIndex,
lzma_stream_flags as BackendStreamFlags,
};
Expand All @@ -47,8 +47,8 @@ use xz_sys::{
lzma_stream_flags as BackendStreamFlags, lzma_stream_footer_decode,
};

#[cfg(feature = "xz")]
const BACKEND_NAME: &str = "xz";
#[cfg(feature = "xz-core")]
const BACKEND_NAME: &str = "xz-core";
#[cfg(feature = "liblzma-sys")]
const BACKEND_NAME: &str = "liblzma-sys";
#[cfg(feature = "xz-sys")]
Expand Down Expand Up @@ -225,7 +225,7 @@ fn usage() -> String {
let mut message = String::new();
message.push_str("Usage:\n");
message.push_str(
" cargo run -p perf-probe --release --no-default-features --features <xz|xz-sys|liblzma-sys> -- \\\n",
" cargo run -p perf-probe --release --no-default-features --features <xz-core|xz-sys|liblzma-sys> -- \\\n",
);
message.push_str(" --workload <encode|decode|size|crc32|crc64> [options]\n\n");
message.push_str("Options:\n");
Expand Down Expand Up @@ -489,7 +489,7 @@ fn fold_bytes(len: usize, data: &[u8]) -> u64 {
}

unsafe fn backend_encode(input: &[u8], preset: u32) -> Vec<u8> {
#[cfg(feature = "xz")]
#[cfg(feature = "xz-core")]
let bound = lzma_stream_buffer_bound(input.len());
#[cfg(any(feature = "xz-sys", feature = "liblzma-sys"))]
let bound = unsafe { lzma_stream_buffer_bound(input.len()) };
Expand Down
Loading