Skip to content

Commit efd41b7

Browse files
committed
refactor(client): continuously download files instead of chunking
This avoid inefficient threshold effect.
1 parent 646e490 commit efd41b7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

mithril-client/src/cardano_database_client/download_unpack.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,19 @@ impl InternalArtifactDownloader {
341341
) -> MithrilResult<()> {
342342
let mut join_set: JoinSet<MithrilResult<()>> = JoinSet::new();
343343

344-
while !tasks.is_empty() {
345-
let tasks_chunk = tasks.pop_up_to_n(max_parallel_downloads);
344+
let initial_tasks_chunk = tasks.pop_up_to_n(max_parallel_downloads);
345+
for task in initial_tasks_chunk {
346+
join_set.spawn(self.spawn_download_future(task));
347+
}
346348

347-
for task in tasks_chunk {
348-
join_set.spawn(self.spawn_download_future(task));
349+
while let Some(result) = join_set.join_next().await {
350+
if let Err(error) = result? {
351+
join_set.abort_all();
352+
anyhow::bail!(error);
349353
}
350-
while let Some(result) = join_set.join_next().await {
351-
if let Err(error) = result? {
352-
join_set.abort_all();
353-
anyhow::bail!(error);
354-
}
354+
355+
if let Some(task) = tasks.pop_front() {
356+
join_set.spawn(self.spawn_download_future(task));
355357
}
356358
}
357359

0 commit comments

Comments
 (0)