1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-12-15 08:16:43 +00:00
This commit is contained in:
2020-05-24 02:22:05 +08:00
parent 04832b8b02
commit 73600d3595
4 changed files with 11 additions and 10 deletions

View File

@@ -583,7 +583,7 @@ func VectorFactory(rng *rand.Rand) eaopt.Genome {
} }
func main3() { func main3() {
numTask := 5 numTask := 20
nodesMap = map[string]Node{} nodesMap = map[string]Node{}
tasksMap = map[string]Task{} tasksMap = map[string]Task{}
@@ -646,7 +646,7 @@ func main3() {
ga.EarlyStop = func(ga *eaopt.GA) bool { ga.EarlyStop = func(ga *eaopt.GA) bool {
gap := math.Abs(ga.HallOfFame[0].Fitness - bestFitness) gap := math.Abs(ga.HallOfFame[0].Fitness - bestFitness)
if gap <= 0.000001 || ga.HallOfFame[0].Fitness >= bestFitness { if gap <= 0.000001 || ga.HallOfFame[0].Fitness >= bestFitness {
if count >= 50 || time.Since(ts) > time.Second*30 { if count >= 30 || time.Since(ts) > time.Second*30 {
fmt.Println("Early Stop") fmt.Println("Early Stop")
return true return true
} else { } else {

View File

@@ -161,7 +161,7 @@ func (jm *JobManager) start() {
if !jm.isRunning { if !jm.isRunning {
break break
} }
time.Sleep(time.Second * 10) time.Sleep(time.Second * 25)
} }
} }

View File

@@ -62,11 +62,11 @@ func (pool *ResourcePool) start() {
for i := 0; i < pool.poolsCount; i++ { for i := 0; i < pool.poolsCount; i++ {
pool.pools = append(pool.pools, PoolSeg{Lock: sync.Mutex{}, IsVirtual: true, ID: i}) pool.pools = append(pool.pools, PoolSeg{Lock: sync.Mutex{}, IsVirtual: true, ID: i})
} }
/* make non-virtual seg */ /* make non-virtual segs */
for i := 0; i < pool.poolsCount/3; i++ { for i := 0; i < pool.poolsCount/3; i++ {
pool.pools[rand.Intn(pool.poolsCount)].IsVirtual = false pool.pools[rand.Intn(pool.poolsCount)].IsVirtual = false
} }
/* make working srg */ /* generate working segs */
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
pool.pools[rand.Intn(pool.poolsCount)].Nodes = map[string]*NodeStatus{} pool.pools[rand.Intn(pool.poolsCount)].Nodes = map[string]*NodeStatus{}
} }

View File

@@ -344,9 +344,10 @@ func (scheduler *SchedulerFair) Schedule(job Job) {
} }
func (scheduler *SchedulerFair) AcquireResource(job Job, task Task, nodes []NodeStatus) NodeStatus { func (scheduler *SchedulerFair) AcquireResource(job Job, task Task, nodes []NodeStatus) NodeStatus {
scheduler.mu.Lock()
defer scheduler.mu.Unlock()
segID := rand.Intn(pool.poolsCount) segID := rand.Intn(pool.poolsCount)
if pool.TotalGPU < 100 {
segID = 0
}
res := NodeStatus{} res := NodeStatus{}
start := &pool.pools[segID] start := &pool.pools[segID]
if start.Nodes == nil { if start.Nodes == nil {
@@ -366,7 +367,7 @@ func (scheduler *SchedulerFair) AcquireResource(job Job, task Task, nodes []Node
allocationType = 1 allocationType = 1
if util, valid := InstanceOfOptimizer().predictUtilGPU(job.Name); valid { if util, valid := InstanceOfOptimizer().predictUtilGPU(job.Name); valid {
for cur := start; ; { for cur := start; cur.ID < cur.Next.ID; {
if _, ok := locks[cur.ID]; !ok { if _, ok := locks[cur.ID]; !ok {
cur.Lock.Lock() cur.Lock.Lock()
locks[cur.ID] = &cur.Lock locks[cur.ID] = &cur.Lock
@@ -430,7 +431,7 @@ func (scheduler *SchedulerFair) AcquireResource(job Job, task Task, nodes []Node
} }
if len(candidates) == 0 && flag { if len(candidates) == 0 && flag {
allocationType = 2 allocationType = 2
for cur := start; ; { for cur := start; cur.ID < cur.Next.ID; {
if _, ok := locks[cur.ID]; !ok { if _, ok := locks[cur.ID]; !ok {
cur.Lock.Lock() cur.Lock.Lock()
locks[cur.ID] = &cur.Lock locks[cur.ID] = &cur.Lock
@@ -471,7 +472,7 @@ func (scheduler *SchedulerFair) AcquireResource(job Job, task Task, nodes []Node
if pool.TotalGPU != 0 && float64(scheduler.UsingGPU)/float64(pool.TotalGPU) >= scheduler.enablePreScheduleRatio && valid { if pool.TotalGPU != 0 && float64(scheduler.UsingGPU)/float64(pool.TotalGPU) >= scheduler.enablePreScheduleRatio && valid {
allocationType = 3 allocationType = 3
for cur := start; ; { for cur := start; cur.ID < cur.Next.ID; {
if _, ok := locks[cur.ID]; !ok { if _, ok := locks[cur.ID]; !ok {
cur.Lock.Lock() cur.Lock.Lock()
locks[cur.ID] = &cur.Lock locks[cur.ID] = &cur.Lock