Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Lift poolCache to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges authored Sep 13, 2022
1 parent 25a1dc5 commit fa40448
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ApiService/ApiService/onefuzzlib/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PoolKey, Pool>();

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) {
Expand Down Expand Up @@ -69,13 +72,10 @@ private async Async.Task<bool> 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<PoolKey, Pool> poolCache) {
var taskIds = tasks.Select(x => x.TaskId).ToHashSet();
var workUnits = new List<WorkUnit>();

// only fetch pools once from storage; see explanation in BuildWorkUnit for more
var poolCache = new Dictionary<PoolKey, Pool>();

BucketConfig? bucketConfig = null;
foreach (var task in tasks) {
if (task.Config.PrereqTasks is List<Guid> prereqTasks && prereqTasks.Any()) {
Expand Down

0 comments on commit fa40448

Please sign in to comment.