1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-07 14:21:55 +00:00

update fair

This commit is contained in:
Newnius 2020-05-28 19:38:46 +08:00
parent 4a91d71c26
commit 911796da2c
3 changed files with 25 additions and 23 deletions

View File

@ -911,6 +911,7 @@ func (pool *ResourcePool) releaseResource(job Job, agent NodeStatus) {
/* in case node is offline */
if !ok {
/* TODO, update usingTotalGPU correctly */
log.Warn("node ", agent.ClientID, " not present")
return
}
for _, gpu := range agent.Status {

View File

@ -250,19 +250,20 @@ func (scheduler *SchedulerCapacity) AcquireResource(job Job) []NodeStatus {
func (scheduler *SchedulerCapacity) ReleaseResource(job Job, agent NodeStatus) {
InstanceOfResourcePool().releaseResource(job, agent)
go func(res NodeStatus) {
scheduler.resourceAllocationsMu.Lock()
if _, ok := scheduler.resourceAllocations[job.Group]; !ok {
scheduler.resourceAllocations[job.Group] = &ResourceCount{}
}
cnt, _ := scheduler.resourceAllocations[job.Group]
cnt.CPU -= res.MemTotal
cnt.Memory -= res.NumCPU
for _, v := range res.Status {
cnt.CPU -= agent.MemTotal
cnt.Memory -= agent.NumCPU
for _, v := range agent.Status {
cnt.NumberGPU --
cnt.MemoryGPU -= v.MemoryTotal
}
scheduler.resourceAllocationsMu.Unlock()
go func(res NodeStatus) {
scheduler.UpdateNextQueue()
}(agent)
}

View File

@ -276,17 +276,17 @@ func (scheduler *SchedulerFair) AcquireResource(job Job) []NodeStatus {
func (scheduler *SchedulerFair) ReleaseResource(job Job, agent NodeStatus) {
InstanceOfResourcePool().releaseResource(job, agent)
go func(res NodeStatus) {
scheduler.resourceAllocationsMu.Lock()
if _, ok := scheduler.resourceAllocations[job.Group]; !ok {
scheduler.resourceAllocations[job.Group] = &ResourceCount{}
}
cnt, _ := scheduler.resourceAllocations[job.Group]
cnt.CPU -= res.NumCPU
cnt.Memory -= res.MemTotal
cnt.NumberGPU -= len(res.Status)
cnt.CPU -= agent.NumCPU
cnt.Memory -= agent.MemTotal
cnt.NumberGPU -= len(agent.Status)
scheduler.resourceAllocationsMu.Unlock()
}(agent)
go func() {
scheduler.UpdateQuota()
}()