Skip to content

perf: reduce murmur call overhead and clarify checksum usage - #24

Merged
tisonkun merged 4 commits into
mainfrom
codex/library-usability-audit
Sep 8, 2026
Merged

perf: reduce murmur call overhead and clarify checksum usage#24
tisonkun merged 4 commits into
mainfrom
codex/library-usability-audit

Conversation

@tisonkun

@tisonkun tisonkun commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Reduce short-chunk MurmurHash3 overhead by allowing its public update and digest methods to inline across crates. Three alternating benchmark runs without LTO on AArch64 showed up to 42% lower latency in the existing short-chunk cases; the performance commit records the toolchain and representative results.

Clarify portable checksum inputs, digest byte order, and MD5 hexadecimal formatting. Consolidate duplicated FNV specification vectors while retaining their unique cases and independent reference comparisons, and correct stale architecture descriptions.

The changes are split into four small commits, each explaining its motivation.

Murmur's public update and digest methods stayed out of line in the
measured consumer build, preventing short writes from optimizing with
their callers. Give these six hot methods ordinary inline hints, as the
other streaming families already do.

With rustc 1.99.0-nightly (3d6c19bb9) on aarch64-apple-darwin, no LTO,
and 16 codegen units, three alternating runs of the existing streaming
benchmarks reduced short-chunk median latency by 6-42%. For example,
x86_32 at 241 B / 17 B chunks went from 123.4 ns to 71.36 ns, while
x64_128 at 4 KiB / 64 B chunks went from 639.0 ns to 521.5 ns.
Bulk-input results stayed within measurement noise; the repository's
ThinLTO configuration also showed no regression in the comparison run.

Verified with cargo x test, including no_std and optimized reference
comparisons. The changelog describes the measured consumer benefit.
The unit and integration suites repeated the same three RFC input/digest
pairs. Keep one authoritative vector table in the library tests and move
the integration-only binary vector there so it also runs under no_std
and Miri. Retain the integration matrix against the independent fnv
implementation and all streaming, offset-basis, and reset coverage.
Stable integer digests do not define a wire format: xxHash uses canonical
big-endian bytes, FNV specifies little-endian bytes, and Murmur's output
word order differs from formatting its returned integer. Explain the
required conversions in the family docs and the portability guide.

Rust Hash also adds type framing and can change its encoding across
compiler versions, even on the same target. Direct checksum callers to
the raw-byte APIs instead of assuming hash_one computes the same input.

Show how to format MD5's byte array as the conventional 32-character
checksum, including leading zeroes, using existing Rust APIs. Exercise
the example as a doctest without introducing a digest wrapper or a new
dependency.
The architecture guide still listed four families and claimed every
128-bit result was u128, omitting MD5's byte digest and finalization.
It also claimed unsafe code was confined to SIMD intrinsics even though
XXH32's block read and XXH3's validated secret reads are outside the
kernel layer. Describe the actual boundaries so maintainers do not rely
on those inaccurate assumptions.

Include opt-in family/std features and the shared I/O adapter location,
and account for MD5's independent reference and RFC-vector coverage in
the README.
@tisonkun
tisonkun marked this pull request as ready for review September 8, 2026 14:59
@tisonkun
tisonkun merged commit 2ec4685 into main Sep 8, 2026
14 checks passed
@tisonkun
tisonkun deleted the codex/library-usability-audit branch September 8, 2026 14:59
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