Used the KMeans classification to classify the tasks.
This commit is contained in:
parent
668ae586fe
commit
34ab753491
2 changed files with 38 additions and 8 deletions
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/mesos/mesos-go/mesosutil"
|
"github.com/mesos/mesos-go/mesosutil"
|
||||||
sched "github.com/mesos/mesos-go/scheduler"
|
sched "github.com/mesos/mesos-go/scheduler"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
@ -68,7 +67,23 @@ func NewBottomHeavy(tasks []def.Task, wattsAsAResource bool, schedTracePrefix st
|
||||||
|
|
||||||
// Separating small tasks from large tasks.
|
// Separating small tasks from large tasks.
|
||||||
// Classification done based on MMPU watts requirements.
|
// Classification done based on MMPU watts requirements.
|
||||||
mid := int(math.Floor((float64(len(tasks)) / 2.0) + 0.5))
|
tasksToClassify := def.TasksToClassify(tasks)
|
||||||
|
classifiedTasks := tasksToClassify.ClassifyTasks(2, func(task def.Task) float64 {
|
||||||
|
if task.ClassToWatts != nil {
|
||||||
|
// taking the aggregate
|
||||||
|
observation := 0.0
|
||||||
|
for _, watts := range task.ClassToWatts {
|
||||||
|
observation += watts
|
||||||
|
}
|
||||||
|
return observation
|
||||||
|
} else if task.Watts != 0.0 {
|
||||||
|
return task.Watts
|
||||||
|
} else {
|
||||||
|
log.Fatal("Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload.")
|
||||||
|
return 0.0 // won't reach here
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
s := &BottomHeavy{
|
s := &BottomHeavy{
|
||||||
base: base{
|
base: base{
|
||||||
wattsAsAResource: wattsAsAResource,
|
wattsAsAResource: wattsAsAResource,
|
||||||
|
@ -80,8 +95,8 @@ func NewBottomHeavy(tasks []def.Task, wattsAsAResource bool, schedTracePrefix st
|
||||||
RecordPCP: false,
|
RecordPCP: false,
|
||||||
schedTrace: log.New(logFile, "", log.LstdFlags),
|
schedTrace: log.New(logFile, "", log.LstdFlags),
|
||||||
},
|
},
|
||||||
smallTasks: tasks[:mid],
|
smallTasks: classifiedTasks[0].Tasks,
|
||||||
largeTasks: tasks[mid+1:],
|
largeTasks: classifiedTasks[1].Tasks,
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/mesos/mesos-go/mesosutil"
|
"github.com/mesos/mesos-go/mesosutil"
|
||||||
sched "github.com/mesos/mesos-go/scheduler"
|
sched "github.com/mesos/mesos-go/scheduler"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
@ -67,7 +66,23 @@ func NewTopHeavy(tasks []def.Task, wattsAsAResource bool, schedTracePrefix strin
|
||||||
|
|
||||||
// Separating small tasks from large tasks.
|
// Separating small tasks from large tasks.
|
||||||
// Classification done based on MMPU watts requirements.
|
// Classification done based on MMPU watts requirements.
|
||||||
mid := int(math.Floor((float64(len(tasks)) / 2.0) + 0.5))
|
tasksToClassify := def.TasksToClassify(tasks)
|
||||||
|
classifiedTasks := tasksToClassify.ClassifyTasks(2, func(task def.Task) float64 {
|
||||||
|
if task.ClassToWatts != nil {
|
||||||
|
// taking the aggregate
|
||||||
|
observation := 0.0
|
||||||
|
for _, watts := range task.ClassToWatts {
|
||||||
|
observation += watts
|
||||||
|
}
|
||||||
|
return observation
|
||||||
|
} else if task.Watts != 0.0 {
|
||||||
|
return task.Watts
|
||||||
|
} else {
|
||||||
|
log.Fatal("Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload.")
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
s := &TopHeavy{
|
s := &TopHeavy{
|
||||||
base: base{
|
base: base{
|
||||||
wattsAsAResource: wattsAsAResource,
|
wattsAsAResource: wattsAsAResource,
|
||||||
|
@ -79,8 +94,8 @@ func NewTopHeavy(tasks []def.Task, wattsAsAResource bool, schedTracePrefix strin
|
||||||
RecordPCP: false,
|
RecordPCP: false,
|
||||||
schedTrace: log.New(logFile, "", log.LstdFlags),
|
schedTrace: log.New(logFile, "", log.LstdFlags),
|
||||||
},
|
},
|
||||||
smallTasks: tasks[:mid],
|
smallTasks: classifiedTasks[0].Tasks,
|
||||||
largeTasks: tasks[mid+1:],
|
largeTasks: classifiedTasks[1].Tasks,
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue