Skip to content

Commit

Permalink
make concurrency configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
cything committed Jan 8, 2025
1 parent 4775242 commit e3b57f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 1 addition & 5 deletions server/src/api/v1/upload_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Config> {
tracing::info!("Using configurations: {:?}", path);

Expand Down

0 comments on commit e3b57f3

Please sign in to comment.