fixed importing issues in power-capping strategies. Changed names of power-capping strategies to extrema.go and progressive-extrema.go
This commit is contained in:
parent
9897c983fe
commit
2cb09ece1f
3 changed files with 19 additions and 17 deletions
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
var RAPLUnits = math.Pow(2, -32)
|
var RAPLUnits = math.Pow(2, -32)
|
||||||
|
|
||||||
func averageNodePowerHistory(history *ring.Ring) float64 {
|
func AverageNodePowerHistory(history *ring.Ring) float64 {
|
||||||
|
|
||||||
total := 0.0
|
total := 0.0
|
||||||
count := 0.0
|
count := 0.0
|
||||||
|
@ -29,7 +29,7 @@ func averageNodePowerHistory(history *ring.Ring) float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Figure a way to merge this and avgpower
|
// TODO: Figure a way to merge this and avgpower
|
||||||
func averageClusterPowerHistory(history *ring.Ring) float64 {
|
func AverageClusterPowerHistory(history *ring.Ring) float64 {
|
||||||
|
|
||||||
total := 0.0
|
total := 0.0
|
||||||
count := 0.0
|
count := 0.0
|
||||||
|
|
|
@ -2,6 +2,7 @@ package pcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/elektron/rapl"
|
"bitbucket.org/sunybingcloud/elektron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/elektron/pcp"
|
||||||
"bufio"
|
"bufio"
|
||||||
"container/ring"
|
"container/ring"
|
||||||
"log"
|
"log"
|
||||||
|
@ -92,34 +93,34 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
|
||||||
powerHistories[host].Value = power
|
powerHistories[host].Value = power
|
||||||
powerHistories[host] = powerHistories[host].Next()
|
powerHistories[host] = powerHistories[host].Next()
|
||||||
|
|
||||||
log.Printf("Host: %s, Power: %f", indexToHost[powerIndex], (power * RAPLUnits))
|
log.Printf("Host: %s, Power: %f", indexToHost[powerIndex], (power * pcp.RAPLUnits))
|
||||||
|
|
||||||
totalPower += power
|
totalPower += power
|
||||||
}
|
}
|
||||||
clusterPower := totalPower * RAPLUnits
|
clusterPower := totalPower * pcp.RAPLUnits
|
||||||
|
|
||||||
clusterPowerHist.Value = clusterPower
|
clusterPowerHist.Value = clusterPower
|
||||||
clusterPowerHist = clusterPowerHist.Next()
|
clusterPowerHist = clusterPowerHist.Next()
|
||||||
|
|
||||||
clusterMean := averageClusterPowerHistory(clusterPowerHist)
|
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
|
||||||
|
|
||||||
log.Printf("Total power: %f, %d Sec Avg: %f", clusterPower, clusterPowerHist.Len(), clusterMean)
|
log.Printf("Total power: %f, %d Sec Avg: %f", clusterPower, clusterPowerHist.Len(), clusterMean)
|
||||||
|
|
||||||
if clusterMean > hiThreshold {
|
if clusterMean > hiThreshold {
|
||||||
log.Printf("Need to cap a node")
|
log.Printf("Need to cap a node")
|
||||||
// Create statics for all victims and choose one to cap
|
// Create statics for all victims and choose one to cap
|
||||||
victims := make([]Victim, 0, 8)
|
victims := make([]pcp.Victim, 0, 8)
|
||||||
|
|
||||||
// TODO: Just keep track of the largest to reduce fron nlogn to n
|
// TODO: Just keep track of the largest to reduce fron nlogn to n
|
||||||
for name, history := range powerHistories {
|
for name, history := range powerHistories {
|
||||||
|
|
||||||
histMean := averageNodePowerHistory(history)
|
histMean := pcp.AverageNodePowerHistory(history)
|
||||||
|
|
||||||
// Consider doing mean calculations using go routines if we need to speed up
|
// Consider doing mean calculations using go routines if we need to speed up
|
||||||
victims = append(victims, Victim{Watts: histMean, Host: name})
|
victims = append(victims, pcp.Victim{Watts: histMean, Host: name})
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(VictimSorter(victims)) // Sort by average wattage
|
sort.Sort(pcp.VictimSorter(victims)) // Sort by average wattage
|
||||||
|
|
||||||
// From best victim to worst, if everyone is already capped NOOP
|
// From best victim to worst, if everyone is already capped NOOP
|
||||||
for _, victim := range victims {
|
for _, victim := range victims {
|
||||||
|
@ -127,7 +128,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
|
||||||
if !cappedHosts[victim.Host] {
|
if !cappedHosts[victim.Host] {
|
||||||
cappedHosts[victim.Host] = true
|
cappedHosts[victim.Host] = true
|
||||||
orderCapped = append(orderCapped, victim.Host)
|
orderCapped = append(orderCapped, victim.Host)
|
||||||
log.Printf("Capping Victim %s Avg. Wattage: %f", victim.Host, victim.Watts*RAPLUnits)
|
log.Printf("Capping Victim %s Avg. Wattage: %f", victim.Host, victim.Watts*pcp.RAPLUnits)
|
||||||
if err := rapl.Cap(victim.Host, "rapl", 50); err != nil {
|
if err := rapl.Cap(victim.Host, "rapl", 50); err != nil {
|
||||||
log.Print("Error capping host")
|
log.Print("Error capping host")
|
||||||
}
|
}
|
|
@ -3,6 +3,7 @@ package pcp
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/sunybingcloud/elektron/constants"
|
"bitbucket.org/sunybingcloud/elektron/constants"
|
||||||
"bitbucket.org/sunybingcloud/elektron/rapl"
|
"bitbucket.org/sunybingcloud/elektron/rapl"
|
||||||
|
"bitbucket.org/sunybingcloud/elektron/pcp"
|
||||||
"bitbucket.org/sunybingcloud/elektron/utilities"
|
"bitbucket.org/sunybingcloud/elektron/utilities"
|
||||||
"bufio"
|
"bufio"
|
||||||
"container/ring"
|
"container/ring"
|
||||||
|
@ -110,16 +111,16 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, pref
|
||||||
powerHistories[host].Value = power
|
powerHistories[host].Value = power
|
||||||
powerHistories[host] = powerHistories[host].Next()
|
powerHistories[host] = powerHistories[host].Next()
|
||||||
|
|
||||||
log.Printf("Host: %s, Power: %f", indexToHost[powerIndex], (power * RAPLUnits))
|
log.Printf("Host: %s, Power: %f", indexToHost[powerIndex], (power * pcp.RAPLUnits))
|
||||||
|
|
||||||
totalPower += power
|
totalPower += power
|
||||||
}
|
}
|
||||||
clusterPower := totalPower * RAPLUnits
|
clusterPower := totalPower * pcp.RAPLUnits
|
||||||
|
|
||||||
clusterPowerHist.Value = clusterPower
|
clusterPowerHist.Value = clusterPower
|
||||||
clusterPowerHist = clusterPowerHist.Next()
|
clusterPowerHist = clusterPowerHist.Next()
|
||||||
|
|
||||||
clusterMean := averageClusterPowerHistory(clusterPowerHist)
|
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
|
||||||
|
|
||||||
log.Printf("Total power: %f, %d Sec Avg: %f", clusterPower, clusterPowerHist.Len(), clusterMean)
|
log.Printf("Total power: %f, %d Sec Avg: %f", clusterPower, clusterPowerHist.Len(), clusterMean)
|
||||||
|
|
||||||
|
@ -128,18 +129,18 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, pref
|
||||||
log.Printf("Cap values of capped victims: %v", cappedVictims)
|
log.Printf("Cap values of capped victims: %v", cappedVictims)
|
||||||
log.Printf("Cap values of victims to uncap: %v", orderCappedVictims)
|
log.Printf("Cap values of victims to uncap: %v", orderCappedVictims)
|
||||||
// Create statics for all victims and choose one to cap
|
// Create statics for all victims and choose one to cap
|
||||||
victims := make([]Victim, 0, 8)
|
victims := make([]pcp.Victim, 0, 8)
|
||||||
|
|
||||||
// TODO: Just keep track of the largest to reduce fron nlogn to n
|
// TODO: Just keep track of the largest to reduce fron nlogn to n
|
||||||
for name, history := range powerHistories {
|
for name, history := range powerHistories {
|
||||||
|
|
||||||
histMean := averageNodePowerHistory(history)
|
histMean := pcp.AverageNodePowerHistory(history)
|
||||||
|
|
||||||
// Consider doing mean calculations using go routines if we need to speed up
|
// Consider doing mean calculations using go routines if we need to speed up
|
||||||
victims = append(victims, Victim{Watts: histMean, Host: name})
|
victims = append(victims, pcp.Victim{Watts: histMean, Host: name})
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(VictimSorter(victims)) // Sort by average wattage
|
sort.Sort(pcp.VictimSorter(victims)) // Sort by average wattage
|
||||||
|
|
||||||
// Finding the best victim to cap in a round robin manner
|
// Finding the best victim to cap in a round robin manner
|
||||||
newVictimFound := false
|
newVictimFound := false
|
Reference in a new issue