Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make concurrency configurable #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions server/src/api/v1/upload_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +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.
///
/// TODO: Make this configurable
Expand Down Expand Up @@ -384,7 +379,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