Skip to content

Commit 2682f85

Browse files
HJLebbinkTest User
authored andcommitted
added CRC32, CRC32C, SHA1, SHA256 and CRC64NVME
1 parent 1b7ae9e commit 2682f85

25 files changed

+4416
-82
lines changed

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ http2 = ["reqwest/http2"]
2424
localhost = []
2525

2626
[workspace.dependencies]
27-
uuid = "1.18"
27+
uuid = "1.19"
2828
futures-util = "0.3"
2929
futures-io = "0.3"
3030
reqwest = { version = "0.12", default-features = false }
@@ -49,7 +49,7 @@ async-stream = "0.3"
4949
async-trait = "0.1"
5050
base64 = "0.22"
5151
chrono = { workspace = true, features = ["serde"] }
52-
crc = "3.4"
52+
crc-fast = "1.8"
5353
dashmap = "6.1.0"
5454
env_logger = "0.11"
5555
hmac = { version = "0.12", optional = true }
@@ -64,6 +64,7 @@ regex = "1.12"
6464
ring = { version = "0.17", optional = true, default-features = false, features = ["alloc"] }
6565
serde = { version = "1.0", features = ["derive"] }
6666
serde_json = "1.0"
67+
sha1 = "0.10"
6768
sha2 = { version = "0.10", optional = true }
6869
urlencoding = "2.1"
6970
xmltree = "0.12"
@@ -104,3 +105,8 @@ name = "load_balancing_with_hooks"
104105
name = "s3-api"
105106
path = "benches/s3/api_benchmarks.rs"
106107
harness = false
108+
109+
[[bench]]
110+
name = "bench_checksums"
111+
path = "benches/s3/bench_checksums.rs"
112+
harness = false

benches/s3/bench_checksums.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// MinIO Rust Library for Amazon S3 Compatible Cloud Storage
2+
// Copyright 2025 MinIO, Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use criterion::{Criterion, Throughput, criterion_group, criterion_main};
17+
use minio::s3::utils::{
18+
crc32_checksum, crc32c, crc64nvme_checksum, md5sum_hash, sha1_hash, sha256_checksum,
19+
};
20+
21+
fn bench_checksums(c: &mut Criterion) {
22+
let sizes = vec![
23+
("1KB", 1024),
24+
("10KB", 10 * 1024),
25+
("100KB", 100 * 1024),
26+
("1MB", 1024 * 1024),
27+
("10MB", 10 * 1024 * 1024),
28+
];
29+
30+
for (name, size) in sizes {
31+
let data = vec![0u8; size];
32+
33+
let mut group = c.benchmark_group(format!("checksum_{}", name));
34+
group.throughput(Throughput::Bytes(size as u64));
35+
36+
group.bench_function("CRC32", |b| b.iter(|| crc32_checksum(&data)));
37+
38+
group.bench_function("CRC32C", |b| b.iter(|| crc32c(&data)));
39+
40+
group.bench_function("CRC64NVME", |b| b.iter(|| crc64nvme_checksum(&data)));
41+
42+
group.bench_function("MD5", |b| b.iter(|| md5sum_hash(&data)));
43+
44+
group.bench_function("SHA1", |b| b.iter(|| sha1_hash(&data)));
45+
46+
group.bench_function("SHA256", |b| b.iter(|| sha256_checksum(&data)));
47+
48+
group.finish();
49+
}
50+
}
51+
52+
criterion_group!(benches, bench_checksums);
53+
criterion_main!(benches);

macros/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ extern crate proc_macro;
7474
/// // this test will not run if the MinIO server is NOT running in Express mode
7575
/// }
7676
/// ```
77+
/// - `ignore`: Mark the test as ignored (skipped by default). Run with `cargo test -- --ignored` to include.
78+
/// ```no_run
79+
/// use minio_common::test_context::TestContext;
80+
/// #[minio_macros::test(ignore = "Requires newer server version")]
81+
/// async fn my_test(ctx: TestContext, bucket_name: String) {
82+
/// // this test is skipped by default
83+
/// }
84+
/// ```
7785
#[proc_macro_attribute]
7886
pub fn test(
7987
args: proc_macro::TokenStream,

macros/src/test_attr.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub(crate) struct MacroArgs {
3232
no_bucket: darling::util::Flag,
3333
object_lock: darling::util::Flag,
3434
no_cleanup: darling::util::Flag,
35+
/// Mark test as ignored (skipped by default, run with `cargo test -- --ignored`)
36+
ignore: Option<String>,
3537
}
3638

3739
impl MacroArgs {
@@ -171,28 +173,33 @@ fn generate_tokio_test_header(args: &MacroArgs, sig: TokenStream) -> TokenStream
171173
.as_ref()
172174
.map(ToString::to_string)
173175
.or(std::env::var("MINIO_TEST_TOKIO_RUNTIME_FLAVOR").ok());
174-
match (flavor, args.worker_threads) {
176+
177+
// Generate #[ignore = "reason"] if specified
178+
let ignore_attr = args
179+
.ignore
180+
.as_ref()
181+
.map(|reason| quote!(#[ignore = #reason]));
182+
183+
let tokio_attr = match (flavor, args.worker_threads) {
175184
(Some(flavor), None) => {
176-
quote!(#[::tokio::test(flavor = #flavor)]
177-
#sig
178-
)
185+
quote!(#[::tokio::test(flavor = #flavor)])
179186
}
180187
(None, Some(worker_threads)) => {
181-
quote!(#[::tokio::test(worker_threads = #worker_threads)]
182-
#sig
183-
)
188+
quote!(#[::tokio::test(worker_threads = #worker_threads)])
184189
}
185190
(None, None) => {
186-
quote!(#[::tokio::test]
187-
#sig
188-
)
191+
quote!(#[::tokio::test])
189192
}
190193
(Some(flavor), Some(worker_threads)) => {
191-
quote!(#[::tokio::test(flavor = #flavor, worker_threads = #worker_threads)]
192-
#sig
193-
)
194+
quote!(#[::tokio::test(flavor = #flavor, worker_threads = #worker_threads)])
194195
}
195-
}
196+
};
197+
198+
quote!(
199+
#ignore_attr
200+
#tokio_attr
201+
#sig
202+
)
196203
}
197204

198205
fn generate_express_skip_logic(args: &MacroArgs, span: proc_macro2::Span) -> TokenStream {

0 commit comments

Comments
 (0)