diff --git a/src/ApiService/ApiService/onefuzzlib/Scheduler.cs b/src/ApiService/ApiService/onefuzzlib/Scheduler.cs index 2e828ca5e53..61261c171dd 100644 --- a/src/ApiService/ApiService/onefuzzlib/Scheduler.cs +++ b/src/ApiService/ApiService/onefuzzlib/Scheduler.cs @@ -33,9 +33,12 @@ public async Async.Task ScheduleTasks() { var buckets = BucketTasks(tasks.Values); + // only fetch pools once from storage; see explanation in BuildWorkUnit for more + var poolCache = new Dictionary(); + foreach (var bucketedTasks in buckets) { foreach (var chunks in bucketedTasks.Chunk(MAX_TASKS_PER_SET)) { - var result = await BuildWorkSet(chunks); + var result = await BuildWorkSet(chunks, poolCache); if (result is var (bucketConfig, workSet)) { if (await ScheduleWorkset(workSet, bucketConfig.pool, bucketConfig.count)) { foreach (var workUnit in workSet.WorkUnits) { @@ -69,13 +72,10 @@ private async Async.Task ScheduleWorkset(WorkSet workSet, Pool pool, long return true; } - private async Async.Task<(BucketConfig, WorkSet)?> BuildWorkSet(Task[] tasks) { + private async Async.Task<(BucketConfig, WorkSet)?> BuildWorkSet(Task[] tasks, Dictionary poolCache) { var taskIds = tasks.Select(x => x.TaskId).ToHashSet(); var workUnits = new List(); - // only fetch pools once from storage; see explanation in BuildWorkUnit for more - var poolCache = new Dictionary(); - BucketConfig? bucketConfig = null; foreach (var task in tasks) { if (task.Config.PrereqTasks is List prereqTasks && prereqTasks.Any()) {