Skip to content

Copy whole-byte Adam7 pixels with a compile-time size - #732

Open
g4lb wants to merge 1 commit into
image-rs:masterfrom
g4lb:perf-adam7-whole-byte-pixels
Open

g4lb wants to merge 1 commit into
image-rs:masterfrom
g4lb:perf-adam7-whole-byte-pixels

Conversation

@g4lb

@g4lb g4lb commented Nov 17, 2026

Copy link
Copy Markdown

expand_pass now copies 3, 4, 6 and 8-byte pixels with a const generic pixel size. Before this change, these sizes used copy_from_slice with a run-time length. The 1, 2, 4, 8 and 16-bit paths do not change. The output does not change.

expand-adam7 Before After Change
size=16/bpp=24 501 ns 202 ns -59.7%
size=16/bpp=32 596 ns 183 ns -69.3%
size=256/bpp=24 104 µs 33.1 µs -68.0%
size=256/bpp=32 118 µs 29.0 µs -75.4%
size=4096/bpp=24 25.2 ms 8.41 ms -66.6%
size=4096/bpp=32 29.7 ms 8.55 ms -71.2%
size=4096/bpp=16 5.86 ms 5.79 ms -1.1% (no change)

Full decode of a 300x300 interlaced image is 42% faster for RGB8, 46% for RGBA8 and 38% to 55% for 16-bit RGB and RGBA. I measured no slowdown on the other expand-adam7 rows or on decoding of interlaced images with 1, 2, 4, 8 and 16-bit pixels. I used 12 interleaved rounds of criterion and a Mann-Whitney test (Apple M5, rustc 1.98.0). I did not measure other architectures.

Checks:

  • cargo test --workspace --all-targets and cargo test --doc pass. cargo build passes on Rust 1.81.0.
  • cargo check --tests --no-default-features passes with the unstable and benchmarks features.
  • Old and new outputs matched on 1M decodes and encodes, including corrupt and truncated files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant