| OLD | NEW |
| 1 package task_scheduler | 1 package scheduling |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "fmt" | 4 "fmt" |
| 5 "path" | 5 "path" |
| 6 "strings" | 6 "strings" |
| 7 | 7 |
| 8 swarming_api "github.com/luci/luci-go/common/api/swarming/swarming/v1" | 8 swarming_api "github.com/luci/luci-go/common/api/swarming/swarming/v1" |
| 9 "go.skia.org/infra/build_scheduler/go/db" | |
| 10 "go.skia.org/infra/go/isolate" | 9 "go.skia.org/infra/go/isolate" |
| 11 "go.skia.org/infra/go/swarming" | 10 "go.skia.org/infra/go/swarming" |
| 11 "go.skia.org/infra/task_scheduler/go/db" |
| 12 ) | 12 ) |
| 13 | 13 |
| 14 // taskCandidate is a struct used for determining which tasks to schedule. | 14 // taskCandidate is a struct used for determining which tasks to schedule. |
| 15 type taskCandidate struct { | 15 type taskCandidate struct { |
| 16 Commits []string | 16 Commits []string |
| 17 IsolatedInput string | 17 IsolatedInput string |
| 18 IsolatedHashes []string | 18 IsolatedHashes []string |
| 19 Name string | 19 Name string |
| 20 Repo string | 20 Repo string |
| 21 Revision string | 21 Revision string |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 Dimensions: dims, | 124 Dimensions: dims, |
| 125 ExecutionTimeoutSecs: int64(swarming.RECOMMENDED_HARD_TI
MEOUT.Seconds()), | 125 ExecutionTimeoutSecs: int64(swarming.RECOMMENDED_HARD_TI
MEOUT.Seconds()), |
| 126 InputsRef: &swarming_api.SwarmingRpcsFilesRef{ | 126 InputsRef: &swarming_api.SwarmingRpcsFilesRef{ |
| 127 Isolated: c.IsolatedInput, | 127 Isolated: c.IsolatedInput, |
| 128 Isolatedserver: isolate.ISOLATE_SERVER_URL, | 128 Isolatedserver: isolate.ISOLATE_SERVER_URL, |
| 129 Namespace: isolate.DEFAULT_NAMESPACE, | 129 Namespace: isolate.DEFAULT_NAMESPACE, |
| 130 }, | 130 }, |
| 131 IoTimeoutSecs: int64(swarming.RECOMMENDED_IO_TIMEOUT.Sec
onds()), | 131 IoTimeoutSecs: int64(swarming.RECOMMENDED_IO_TIMEOUT.Sec
onds()), |
| 132 }, | 132 }, |
| 133 Tags: db.TagsForTask(c.Name, id, c.TaskSpec.Priority, c.Repo, c.
Revision, dimsMap), | 133 Tags: db.TagsForTask(c.Name, id, c.TaskSpec.Priority, c.Repo, c.
Revision, dimsMap), |
| 134 » » User: "skia-build-scheduler", | 134 » » User: "skia-task-scheduler", |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 // allDepsMet determines whether all dependencies for the given task candidate | 138 // allDepsMet determines whether all dependencies for the given task candidate |
| 139 // have been satisfied, and if so, returns their isolated outputs. | 139 // have been satisfied, and if so, returns their isolated outputs. |
| 140 func (c *taskCandidate) allDepsMet(cache db.TaskCache) (bool, []string, error) { | 140 func (c *taskCandidate) allDepsMet(cache db.TaskCache) (bool, []string, error) { |
| 141 isolatedHashes := make([]string, 0, len(c.TaskSpec.Dependencies)) | 141 isolatedHashes := make([]string, 0, len(c.TaskSpec.Dependencies)) |
| 142 for _, depName := range c.TaskSpec.Dependencies { | 142 for _, depName := range c.TaskSpec.Dependencies { |
| 143 d, err := cache.GetTaskForCommit(c.Repo, c.Revision, depName) | 143 d, err := cache.GetTaskForCommit(c.Repo, c.Revision, depName) |
| 144 if err != nil { | 144 if err != nil { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 158 // taskCandidateSlice is an alias used for sorting a slice of taskCandidates. | 158 // taskCandidateSlice is an alias used for sorting a slice of taskCandidates. |
| 159 type taskCandidateSlice []*taskCandidate | 159 type taskCandidateSlice []*taskCandidate |
| 160 | 160 |
| 161 func (s taskCandidateSlice) Len() int { return len(s) } | 161 func (s taskCandidateSlice) Len() int { return len(s) } |
| 162 func (s taskCandidateSlice) Swap(i, j int) { | 162 func (s taskCandidateSlice) Swap(i, j int) { |
| 163 s[i], s[j] = s[j], s[i] | 163 s[i], s[j] = s[j], s[i] |
| 164 } | 164 } |
| 165 func (s taskCandidateSlice) Less(i, j int) bool { | 165 func (s taskCandidateSlice) Less(i, j int) bool { |
| 166 return s[i].Score > s[j].Score // candidates sort in decreasing order. | 166 return s[i].Score > s[j].Score // candidates sort in decreasing order. |
| 167 } | 167 } |
| OLD | NEW |