mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-12-15 08:16:43 +00:00
add optimizer
This commit is contained in:
@@ -28,6 +28,7 @@ type ResourcePool struct {
|
|||||||
counterTotal int
|
counterTotal int
|
||||||
|
|
||||||
bindings map[string]map[string]bool
|
bindings map[string]map[string]bool
|
||||||
|
utils map[string][]int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pool *ResourcePool) start() {
|
func (pool *ResourcePool) start() {
|
||||||
@@ -111,6 +112,16 @@ func (pool *ResourcePool) update(node NodeStatus) {
|
|||||||
pool.mu.Lock()
|
pool.mu.Lock()
|
||||||
defer pool.mu.Unlock()
|
defer pool.mu.Unlock()
|
||||||
|
|
||||||
|
go func(node NodeStatus) {
|
||||||
|
for _, gpu := range node.Status {
|
||||||
|
if _, ok := pool.bindings[gpu.UUID]; ok {
|
||||||
|
if len(pool.bindings[gpu.UUID]) == 1 {
|
||||||
|
pool.utils[gpu.UUID] = append(pool.utils[gpu.UUID], gpu.UtilizationGPU)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}(node)
|
||||||
|
|
||||||
pool.heartBeat[node.ClientID] = time.Now()
|
pool.heartBeat[node.ClientID] = time.Now()
|
||||||
|
|
||||||
pool.counterTotal++
|
pool.counterTotal++
|
||||||
@@ -198,17 +209,29 @@ func (pool *ResourcePool) releaseNetwork(network string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pool *ResourcePool) attach(GPU string, job string) {
|
func (pool *ResourcePool) attach(GPU string, job string) {
|
||||||
|
if _, ok := pool.bindings[GPU]; !ok {
|
||||||
|
pool.bindings[GPU] = map[string]bool{}
|
||||||
|
}
|
||||||
|
pool.bindings[GPU][job] = true
|
||||||
|
|
||||||
|
if _, ok := pool.utils[GPU]; !ok {
|
||||||
|
pool.utils[GPU] = []int{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pool *ResourcePool) detach(GPU string, jobName string) {
|
||||||
if _, ok := pool.bindings[GPU]; ok {
|
if _, ok := pool.bindings[GPU]; ok {
|
||||||
pool.bindings[GPU][job] = true
|
if len(pool.bindings[GPU]) == 1 {
|
||||||
|
InstanceOptimizer().feed(jobName, pool.utils[GPU])
|
||||||
|
pool.utils[GPU] = []int{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (pool *ResourcePool) detach(GPU string, job string) {
|
|
||||||
if list, ok := pool.bindings[GPU]; ok {
|
if list, ok := pool.bindings[GPU]; ok {
|
||||||
delete(list, job)
|
delete(list, jobName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pool *ResourcePool) getBindings() map[string]map[string]bool{
|
func (pool *ResourcePool) getBindings() map[string]map[string]bool {
|
||||||
return pool.bindings
|
return pool.bindings
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ func (scheduler *SchedulerFair) Start() {
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
log.Debug("Scheduling")
|
log.Debug("Scheduling")
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Millisecond * 100)
|
||||||
scheduler.scheduling.Lock()
|
scheduler.scheduling.Lock()
|
||||||
scheduler.mu.Lock()
|
scheduler.mu.Lock()
|
||||||
queue := scheduler.nextQueue
|
queue := scheduler.nextQueue
|
||||||
|
|||||||
Reference in New Issue
Block a user