mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-07 14:21:55 +00:00
update
This commit is contained in:
parent
bfd63fda5f
commit
39d7ebd93d
@ -13,7 +13,7 @@ type SchedulerFair struct {
|
|||||||
historyMu sync.Mutex
|
historyMu sync.Mutex
|
||||||
|
|
||||||
jobs map[string]*JobManager
|
jobs map[string]*JobManager
|
||||||
queues map[string][]Job
|
queues map[string]JobList
|
||||||
queuesMu sync.Mutex
|
queuesMu sync.Mutex
|
||||||
|
|
||||||
drfyarn bool
|
drfyarn bool
|
||||||
@ -35,12 +35,26 @@ type SchedulerFair struct {
|
|||||||
allocatingGPUMu sync.Mutex
|
allocatingGPUMu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type JobList []Job
|
||||||
|
|
||||||
|
func (jobs JobList) Len() int {
|
||||||
|
return len(jobs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jobs JobList) Less(i, j int) bool {
|
||||||
|
return jobs[i].BasePriority < jobs[j].BasePriority
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jobs JobList) Swap(i, j int) {
|
||||||
|
jobs[i], jobs[j] = jobs[j], jobs[i]
|
||||||
|
}
|
||||||
|
|
||||||
func (scheduler *SchedulerFair) Start() {
|
func (scheduler *SchedulerFair) Start() {
|
||||||
log.Info("JS (fairness) started")
|
log.Info("JS (fairness) started")
|
||||||
|
|
||||||
scheduler.jobs = map[string]*JobManager{}
|
scheduler.jobs = map[string]*JobManager{}
|
||||||
scheduler.history = []*Job{}
|
scheduler.history = []*Job{}
|
||||||
scheduler.queues = map[string][]Job{}
|
scheduler.queues = map[string]JobList{}
|
||||||
scheduler.queues["default"] = []Job{}
|
scheduler.queues["default"] = []Job{}
|
||||||
scheduler.drfyarn = false
|
scheduler.drfyarn = false
|
||||||
scheduler.enableBorrow = true
|
scheduler.enableBorrow = true
|
||||||
@ -411,6 +425,7 @@ func (scheduler *SchedulerFair) Schedule(job Job) {
|
|||||||
scheduler.queues[queue][index] = job
|
scheduler.queues[queue][index] = job
|
||||||
|
|
||||||
job.Status = Created
|
job.Status = Created
|
||||||
|
job.BasePriority = float64(len(scheduler.queues[queue])) / 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scheduler *SchedulerFair) AcquireResource(job Job) []NodeStatus {
|
func (scheduler *SchedulerFair) AcquireResource(job Job) []NodeStatus {
|
||||||
@ -498,7 +513,7 @@ func (scheduler *SchedulerFair) UpdateQuota() {
|
|||||||
}
|
}
|
||||||
weights += InstanceOfGroupManager().groups[queue].Weight
|
weights += InstanceOfGroupManager().groups[queue].Weight
|
||||||
request := ResourceCount{}
|
request := ResourceCount{}
|
||||||
for _, job := range jobs {
|
for i, job := range jobs {
|
||||||
GPU := 0
|
GPU := 0
|
||||||
CPU := 0
|
CPU := 0
|
||||||
Memory := 0
|
Memory := 0
|
||||||
@ -510,7 +525,12 @@ func (scheduler *SchedulerFair) UpdateQuota() {
|
|||||||
request.NumberGPU += GPU
|
request.NumberGPU += GPU
|
||||||
request.CPU += CPU
|
request.CPU += CPU
|
||||||
request.Memory += Memory
|
request.Memory += Memory
|
||||||
|
if job.Priority == jobs[0].Priority {
|
||||||
|
scheduler.queues[queue][i].BasePriority += 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
sort.Sort(sort.Reverse(scheduler.queues[queue]))
|
||||||
|
|
||||||
if quota, ok := scheduler.queuesQuota[queue]; ok && quota.NumberGPU >= request.NumberGPU*1000 {
|
if quota, ok := scheduler.queuesQuota[queue]; ok && quota.NumberGPU >= request.NumberGPU*1000 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ type Job struct {
|
|||||||
Tasks []Task `json:"tasks"`
|
Tasks []Task `json:"tasks"`
|
||||||
Workspace string `json:"workspace"`
|
Workspace string `json:"workspace"`
|
||||||
Group string `json:"group"`
|
Group string `json:"group"`
|
||||||
|
BasePriority float64 `json:"base_priority"`
|
||||||
Priority JobPriority `json:"priority"`
|
Priority JobPriority `json:"priority"`
|
||||||
RunBefore int `json:"run_before"`
|
RunBefore int `json:"run_before"`
|
||||||
CreatedAt int `json:"created_at"`
|
CreatedAt int `json:"created_at"`
|
||||||
|
Loading…
Reference in New Issue
Block a user