perf: major encode/decode optimization via const copy_from_slice and batch zero fill

Encode: rewrite to two-pass (scan + copy_from_slice) leveraging Rust 1.93's
const fn copy_from_slice for memcpy at runtime while keeping const fn encode.
Sub-slice scan pattern helps LLVM eliminate bounds checks. Added zero byte
fast path for all-zeros workloads. Now leads corncobs on nonzero/mixed encode.

Decode: batch consecutive 0x01 codes (all-zeros data) and fill zeros via
memset instead of per-byte loop. Decode zeros throughput jumps from ~1.2 GB/s
to ~4.6 GB/s, now 3x faster than corncobs on that workload.

Bump MSRV 1.83 → 1.93 for const copy_from_slice.
Update dev-deps: cobs 0.3→0.5, criterion 0.5→0.8, rand 0.8→0.10.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 4.6 committed 2026-03-30 23:00:33 -06:00
1 parent 3d674989ab
commit adb0db7ee5
4 files changed
+73 -27

No files matched your search

+4 -4
View File
@@ -2,7 +2,7 @@
name = "ucobs"
version = "0.2.0"
edition = "2021"
rust-version = "1.83"
rust-version = "1.93"
license = "MIT"
description = "μCOBS — Consistent Overhead Byte Stuffing. no_std, zero-alloc, fastest, most-tested COBS implementation."
authors = ["Stephen Waits <steve@waits.net>"]
@@ -23,11 +23,11 @@ unsafe_code = "forbid"
all-features = true
[dev-dependencies]
cobs = "0.3"
cobs = "0.5"
corncobs = "0.1"
criterion = { version = "0.5", features = ["html_reports"] }
criterion = { version = "0.8", features = ["html_reports"] }
proptest = "1"
rand = "0.8"
rand = "0.10"
[[bench]]
name = "bench"