Add the parameter, which replaces . This is to accommodate different storage media such as HDD and NVMe.

This commit is contained in:
perrynzhou@gmail.com 2025-12-10 06:43:51 +08:00
parent d769a7be5d
commit 4d124e1c76
2 changed files with 9 additions and 3 deletions

View file

@ -39,8 +39,6 @@ use crate::encryption::EncryptionParams;
use crate::error::*;
use crate::website::X_AMZ_WEBSITE_REDIRECT_LOCATION;
const PUT_BLOCKS_MAX_PARALLEL: usize = 3;
pub(crate) struct SaveStreamResult {
pub(crate) version_uuid: Uuid,
pub(crate) version_timestamp: u64,
@ -493,7 +491,7 @@ pub(crate) async fn read_and_put_blocks<S: Stream<Item = Result<Bytes, Error>> +
};
let recv_next = async {
// If more than a maximum number of writes are in progress, don't add more for now
if currently_running >= PUT_BLOCKS_MAX_PARALLEL {
if currently_running >= ctx.garage.config.put_blocks_max_parallel {
futures::future::pending().await
} else {
block_rx3.recv().await

View file

@ -45,6 +45,11 @@ pub struct Config {
)]
pub block_size: usize,
/// Maximum number of parallel block writes per PUT request
/// Higher values improve throughput but increase memory usage
/// Default: 3, Recommended: 10-30 for NVMe, 3-10 for HDD
#[serde(default = "default_put_blocks_max_parallel")]
pub put_blocks_max_parallel: usize,
/// Number of replicas. Can be any positive integer, but uneven numbers are more favorable.
/// - 1 for single-node clusters, or to disable replication
/// - 3 is the recommended and supported setting.
@ -267,6 +272,9 @@ pub struct KubernetesDiscoveryConfig {
pub skip_crd: bool,
}
pub fn default_put_blocks_max_parallel() -> usize {
3
}
/// Read and parse configuration
pub fn read_config(config_file: PathBuf) -> Result<Config, Error> {
let config = std::fs::read_to_string(config_file)?;