Add criterion benchmarks and live throughput bench script#3
Merged
Conversation
- Add lib.rs to expose modules for external benchmarking - Criterion benchmarks for crypto (md4, sha256, hmac_md5, hmac_sha256, hex_encode) and protocol (header encode/decode, frame_packet, build_request, decode responses, parse_directory_entries, NtStatus) - Live throughput script (scripts/bench-live.sh): single-file write/read at 1MB-1GB, multi-file writes, ~10GB total data volume - Makefile targets: make bench, make bench-live
- Document fmt/clippy/rustdoc/test checks to run before creating PRs - Add Default impls for MultipartStore and XmlWriter (clippy::new_without_default)
There was a problem hiding this comment.
Pull request overview
This PR turns the project into a dual bin+lib crate to enable external benchmarking, and adds both Criterion-based microbenchmarks and a live throughput benchmarking script wired into the Makefile.
Changes:
- Add
src/lib.rsand a[lib]target sospiceio::{crypto,s3,smb}can be used from benches and external tooling. - Add Criterion benches for crypto primitives and SMB protocol encode/decode paths.
- Add a
bench-livescript and Makefile targets for running micro + live throughput benchmarks.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/main.rs |
Switches from local mod declarations to importing modules from the new spiceio library crate. |
src/lib.rs |
Introduces the library crate entrypoint exporting crypto, s3, and smb modules. |
benches/crypto_bench.rs |
Adds Criterion benchmarks for crypto helpers exposed via the library crate. |
benches/protocol_bench.rs |
Adds Criterion benchmarks for SMB protocol framing/encoding/decoding paths. |
scripts/bench-live.sh |
Adds a live, end-to-end throughput benchmark runner against a locally started spiceio. |
Makefile |
Adds bench and bench-live targets to run Criterion and the live script. |
Cargo.toml |
Adds [lib], Criterion dev-dependency, and bench target configs. |
Cargo.lock |
Updates lockfile to include Criterion and transitive dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add --locked to bench and bench-live build commands - Use /dev/zero instead of /dev/urandom to avoid RNG bottleneck - Remove unused human_size function - Fix aggregate totals and use MiB units consistently - Update script header with actual dependencies - Pre-allocate buffers outside b.iter in protocol benchmarks - Use typed enums (DesiredAccess, ShareAccess, etc.) instead of raw constants
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Wrap all benchmark return values in black_box to prevent elision - CI: compile-check benchmarks (--no-run) instead of running them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/lib.rsto expose modules for external benchmarkingcargo bench): 21 benchmarks across crypto primitives and SMB protocol encoding/decodingmake bench-live): single-file write/read at 1MB–1GB, multi-file writes, ~10GB totalmake bench,make bench-liveTest plan
cargo testpasses (28 tests)cargo benchruns all 21 benchmarksmake bench-liveruns against NAS (requires SPICEIO_SMB_USER/PASS)