From f10792b12616db8be4800398ef8eff0c6c1ffa2b Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 17 Jul 2023 18:07:54 +0200 Subject: dashboard: rename createPatchTestingJobs() to jobFromBugSample() This will let us use the same code for sampling-based generation of bisection jobs as well. --- dashboard/app/jobs.go | 12 ++++++++---- dashboard/dashapi/dashapi.go | 4 ++++ syz-ci/jobs.go | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go index 4a3537add..6cbd4bfc8 100644 --- a/dashboard/app/jobs.go +++ b/dashboard/app/jobs.go @@ -322,9 +322,9 @@ func getNextJob(c context.Context, managers map[string]dashapi.ManagerJobs) (*Jo var handlers []func(context.Context, map[string]dashapi.ManagerJobs) (*Job, *db.Key, error) // Let's alternate handlers, so that neither patch tests nor bisections overrun one another. if timeNow(c).UnixMilli()%2 == 0 { - handlers = append(handlers, createPatchTestingJobs, createBisectJob) + handlers = append(handlers, jobFromBugSample, createBisectJob) } else { - handlers = append(handlers, createBisectJob, createPatchTestingJobs) + handlers = append(handlers, createBisectJob, jobFromBugSample) } for _, f := range handlers { job, jobKey, err := f(c, managers) @@ -382,11 +382,15 @@ func throttleJobGeneration(c context.Context, managers map[string]dashapi.Manage return nil } -func createPatchTestingJobs(c context.Context, managers map[string]dashapi.ManagerJobs) (*Job, +// Randomly sample a subset of open bugs with reproducers and try to generate +// a job for them. +// Suitable for cases when we must look deeper than just into Bug fields. +// Sampling allows to evenly spread the load over time. +func jobFromBugSample(c context.Context, managers map[string]dashapi.ManagerJobs) (*Job, *db.Key, error) { var managersList []string for name, jobs := range managers { - if !jobs.TestPatches { + if !jobs.Any() { continue } managersList = append(managersList, name) diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go index 21ba8df1a..00d7a9182 100644 --- a/dashboard/dashapi/dashapi.go +++ b/dashboard/dashapi/dashapi.go @@ -171,6 +171,10 @@ type ManagerJobs struct { BisectFix bool } +func (m ManagerJobs) Any() bool { + return m.TestPatches || m.BisectCause || m.BisectFix +} + type JobPollResp struct { ID string Type JobType diff --git a/syz-ci/jobs.go b/syz-ci/jobs.go index 89276c04e..36b362ab9 100644 --- a/syz-ci/jobs.go +++ b/syz-ci/jobs.go @@ -297,7 +297,7 @@ func (jp *JobProcessor) pollJobs() { BisectCause: jobs.BisectCause, BisectFix: jobs.BisectFix, } - if apiJobs.TestPatches || apiJobs.BisectCause || apiJobs.BisectFix { + if apiJobs.Any() { poll.Managers[mgr.name] = apiJobs } } -- cgit mrf-deployment