Compare commits

...

4 Commits

Author SHA1 Message Date
houseme 15a296f65a test(put): align eager boundary assertions
Co-Authored-By: heihutu <heihutu@gmail.com>
2026-08-30 05:01:48 +08:00
houseme abc89e8baa Merge remote-tracking branch 'origin/main' into houseme/fix-put-small-eager-1mib 2026-08-30 04:37:30 +08:00
houseme 922bfecafc Merge branch 'main' into houseme/fix-put-small-eager-1mib 2026-08-30 04:01:29 +08:00
houseme dd0b230a1f perf(storage): keep 1MiB PUTs on eager path
Co-Authored-By: heihutu <heihutu@gmail.com>
2026-08-30 03:51:54 +08:00
+18 -16
View File
@@ -25,15 +25,14 @@ const ENV_ZERO_COPY_EAGER_PUT_MAX_SIZE_BYTES: &str = "RUSTFS_ZERO_COPY_EAGER_PUT
/// Maximum body size materialized by the ordinary eager PUT path.
///
/// Bodies above this boundary stay streaming so a 1 MiB request does not
/// reserve a full request-sized buffer while the EC writer is consuming it.
/// The environment override keeps the boundary reversible for workload A/B
/// tests and for deployments whose measured workload favors eager ingestion.
/// Bodies above this boundary stay streaming while the EC writer consumes them.
/// The environment override keeps the boundary reversible for workload A/B tests
/// and for deployments whose measured workload favors streaming ingestion.
const ENV_SMALL_EAGER_PUT_MAX_SIZE_BYTES: &str = "RUSTFS_SMALL_EAGER_PUT_MAX_SIZE_BYTES";
const DEFAULT_ZERO_COPY_EAGER_PUT_MAX_SIZE_BYTES: usize = 16 * 1024 * 1024;
const DEFAULT_SMALL_EAGER_PUT_MAX_SIZE_BYTES: usize = 512 * 1024;
const DEFAULT_SMALL_EAGER_PUT_MAX_SIZE_BYTES: usize = 1024 * 1024;
/// Keep the eager buffer bounded as concurrent PUTs rise. The thresholds are
/// deliberately conservative: tiny objects remain eager, while bursty
@@ -2375,22 +2374,25 @@ mod tests {
assert!(should_use_small_eager_put_path(1024, &headers, false, false, false));
assert!(should_use_small_eager_put_path(128 * 1024, &headers, false, false, false));
assert!(should_use_small_eager_put_path(512 * 1024, &headers, false, false, false));
assert!(!should_use_small_eager_put_path(512 * 1024 + 1, &headers, false, false, false));
assert!(!should_use_small_eager_put_path(1024 * 1024, &headers, false, false, false));
assert!(should_use_small_eager_put_path(1024 * 1024, &headers, false, false, false));
assert!(!should_use_small_eager_put_path(1024 * 1024 + 1, &headers, false, false, false));
}
#[test]
fn select_put_path_switches_at_small_eager_boundary() {
let headers = HeaderMap::new();
let (small_path, _, use_zero_copy, use_small_eager) = select_put_path(512 * 1024, &headers, false, false, false);
let (small_path, _, use_zero_copy, use_small_eager) = select_put_path(1024 * 1024, &headers, false, false, false);
assert_eq!(small_path, "small_eager");
assert!(!use_zero_copy);
assert!(use_small_eager);
let (streaming_path, _, use_zero_copy, use_small_eager) = select_put_path(512 * 1024 + 1, &headers, false, false, false);
assert_eq!(streaming_path, "streaming");
assert!(!use_zero_copy);
// The small-eager boundary is crossed first, then the existing
// zero-copy precedence applies to objects just above 1 MiB.
let (zero_copy_path, _, use_zero_copy, use_small_eager) =
select_put_path(1024 * 1024 + 1, &headers, false, false, false);
assert_eq!(zero_copy_path, "zero_copy_eager");
assert!(use_zero_copy);
assert!(!use_small_eager);
}
@@ -2472,10 +2474,10 @@ mod tests {
#[test]
fn dynamic_small_eager_threshold_sheds_memory_only_above_concurrency_limits() {
assert_eq!(dynamic_small_eager_put_max_size_bytes(0), 512 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(SMALL_EAGER_CONCURRENCY_SOFT_LIMIT), 512 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(SMALL_EAGER_CONCURRENCY_SOFT_LIMIT + 1), 256 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(SMALL_EAGER_CONCURRENCY_HARD_LIMIT + 1), 128 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(0), 1024 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(SMALL_EAGER_CONCURRENCY_SOFT_LIMIT), 1024 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(SMALL_EAGER_CONCURRENCY_SOFT_LIMIT + 1), 512 * 1024);
assert_eq!(dynamic_small_eager_put_max_size_bytes(SMALL_EAGER_CONCURRENCY_HARD_LIMIT + 1), 256 * 1024);
}
#[test]
@@ -2486,7 +2488,7 @@ mod tests {
assert_eq!(path, "small_eager");
assert!(small_eager);
let (path, _, _, small_eager) = select_put_path_with_concurrency(256 * 1024, &headers, false, false, false, 256);
let (path, _, _, small_eager) = select_put_path_with_concurrency(256 * 1024 + 1, &headers, false, false, false, 256);
assert_eq!(path, "streaming");
assert!(!small_eager);
}