Skip to main content

effective_in_flight

Function effective_in_flight 

Source
pub fn effective_in_flight(max_concurrency: usize, part_size: u64) -> usize
Expand description

Compute how many part PUTs to keep in flight, given the caller’s max_concurrency (already defaulted to DEFAULT_MAX_CONCURRENCY) and the SERVER’s actual returned part_size.

Peak buffered memory is in_flight * part_size, so we cap in-flight at UPLOAD_MEMORY_BUDGET / part_size, then at max_concurrency. Normal 8 MiB parts give 256/8 = 32, capped to max_concurrency; a 64 MiB part gives 4.

max_concurrency is honored as an explicit floor: a caller asking for 1 (or 0) gets serial uploads (1), so the budget never raises concurrency above what was requested. The budget-derived count itself has a floor of 1 (you must keep at least one part in flight to make progress), so the overall result is always >= 1.

Pure and total: a zero part_size is treated as 1 to avoid division by zero.