GenericDirectUploadService: Use ParallelLimit

Instead of subgrouping parallel tasks into groups of
MaxConcurrentStatCalls size and running these groups sequentially.
The advantage is that now the next task will run just after
some task has ended. Before, the next group was run when
all tasks in the previous group have finished.

Reuses new ParallelLimit functionality introduced here:
b6208ab34a

Amends f2d50ba6ff

Change-Id: I422c86184d62aefc92d94adb58cdb7b1e38232f2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2023-01-06 16:38:59 +01:00
parent fb477d6567
commit 13fa4d5c02

View File

@@ -71,18 +71,6 @@ QList<DeployableFile> collectFilesToUpload(const DeployableFile &deployable)
return collected; return collected;
} }
static Group packIntoOptionalParallelGroups(const QList<TaskItem> &tasks)
{
QList<TaskItem> groups;
int i = 0;
while (i < tasks.size()) {
const QList<TaskItem> subTasks = tasks.mid(i, MaxConcurrentStatCalls);
i += subTasks.size();
groups.append(Group { QList<TaskItem> {optional, parallel} + subTasks });
}
return Group { QList<TaskItem> {optional} + groups };
}
} // namespace Internal } // namespace Internal
using namespace Internal; using namespace Internal;
@@ -188,12 +176,12 @@ TaskItem GenericDirectUploadServicePrivate::statTree(const TreeStorage<UploadSto
const auto setupHandler = [=](TaskTree &tree) { const auto setupHandler = [=](TaskTree &tree) {
UploadStorage *storagePtr = storage.activeStorage(); UploadStorage *storagePtr = storage.activeStorage();
const QList<DeployableFile> files = filesToStat(storagePtr); const QList<DeployableFile> files = filesToStat(storagePtr);
QList<TaskItem> statList; QList<TaskItem> statList{optional, ParallelLimit(MaxConcurrentStatCalls)};
for (const DeployableFile &file : std::as_const(files)) { for (const DeployableFile &file : std::as_const(files)) {
QTC_ASSERT(file.isValid(), continue); QTC_ASSERT(file.isValid(), continue);
statList.append(statTask(storagePtr, file, statEndHandler)); statList.append(statTask(storagePtr, file, statEndHandler));
} }
tree.setupRoot(packIntoOptionalParallelGroups(statList)); tree.setupRoot({statList});
}; };
return Tree(setupHandler); return Tree(setupHandler);
} }
@@ -273,14 +261,14 @@ TaskItem GenericDirectUploadServicePrivate::chmodTree(const TreeStorage<UploadSt
if (file.isExecutable()) if (file.isExecutable())
filesToChmod << file; filesToChmod << file;
} }
QList<TaskItem> chmodList; QList<TaskItem> chmodList{optional, ParallelLimit(MaxConcurrentStatCalls)};
for (const DeployableFile &file : std::as_const(filesToChmod)) { for (const DeployableFile &file : std::as_const(filesToChmod)) {
QTC_ASSERT(file.isValid(), continue); QTC_ASSERT(file.isValid(), continue);
chmodList.append(chmodTask(file)); chmodList.append(chmodTask(file));
} }
tree.setupRoot(packIntoOptionalParallelGroups(chmodList)); tree.setupRoot({chmodList});
}; };
return Tree {setupChmodHandler}; return Tree(setupChmodHandler);
} }
Group GenericDirectUploadService::deployRecipe() Group GenericDirectUploadService::deployRecipe()