From e3b57f3eb6578913b151fa3465506d3c2b3c2c46 Mon Sep 17 00:00:00 2001 From: cy Date: Tue, 7 Jan 2025 21:13:42 -0500 Subject: [PATCH] make concurrency configurable --- server/src/api/v1/upload_path.rs | 6 +----- server/src/config.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/server/src/api/v1/upload_path.rs b/server/src/api/v1/upload_path.rs index 049795d0..2e629055 100644 --- a/server/src/api/v1/upload_path.rs +++ b/server/src/api/v1/upload_path.rs @@ -50,10 +50,6 @@ use crate::database::entity::object::{self, Entity as Object, InsertExt}; use crate::database::entity::Json as DbJson; use crate::database::{AtticDatabase, ChunkGuard, NarGuard}; -/// Number of chunks to upload to the storage backend at once. -/// -/// TODO: Make this configurable -const CONCURRENT_CHUNK_UPLOADS: usize = 10; /// The maximum size of the upload info JSON. /// @@ -384,7 +380,7 @@ async fn upload_path_new_chunked( chunking_config.max_size, ); - let upload_chunk_limit = Arc::new(Semaphore::new(CONCURRENT_CHUNK_UPLOADS)); + let upload_chunk_limit = Arc::new(Semaphore::new(chunking_config.concurrent_chunk_uploads)); let mut futures = Vec::new(); let mut chunk_idx = 0; diff --git a/server/src/config.rs b/server/src/config.rs index 11e1f8d0..01a45d35 100644 --- a/server/src/config.rs +++ b/server/src/config.rs @@ -265,6 +265,12 @@ pub struct ChunkingConfig { /// The preferred maximum size of a chunk, in bytes. #[serde(rename = "max-size")] pub max_size: usize, + + /// Number of chunks to upload to the storage backend + /// at once. By default, this is 10. + #[serde(rename = "concurrent-chunk-uploads")] + #[serde(default = "default_concurrent_chunk_uploads")] + pub concurrent_chunk_uploads: usize, } /// Compression configuration. @@ -558,6 +564,10 @@ fn default_default_retention_period() -> Duration { Duration::ZERO } +fn default_concurrent_chunk_uploads() -> usize { + 10 +} + fn load_config_from_path(path: &Path) -> Result { tracing::info!("Using configurations: {:?}", path);