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:
Pradyumna Kaushik 2017-09-26 00:26:01 -04:00
parent 9897c983fe
commit 2cb09ece1f
3 changed files with 19 additions and 17 deletions

View file

@ -7,7 +7,7 @@ import (
var RAPLUnits = math.Pow(2, -32)
func averageNodePowerHistory(history *ring.Ring) float64 {
func AverageNodePowerHistory(history *ring.Ring) float64 {
total := 0.0
count := 0.0
@ -29,7 +29,7 @@ func averageNodePowerHistory(history *ring.Ring) float64 {
}
// TODO: Figure a way to merge this and avgpower
func averageClusterPowerHistory(history *ring.Ring) float64 {
func AverageClusterPowerHistory(history *ring.Ring) float64 {
total := 0.0
count := 0.0

View file

@ -2,6 +2,7 @@ package pcp
import (
"bitbucket.org/sunybingcloud/elektron/rapl"
"bitbucket.org/sunybingcloud/elektron/pcp"
"bufio"
"container/ring"
"log"
@ -92,34 +93,34 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
powerHistories[host].Value = power
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
}
clusterPower := totalPower * RAPLUnits
clusterPower := totalPower * pcp.RAPLUnits
clusterPowerHist.Value = clusterPower
clusterPowerHist = clusterPowerHist.Next()
clusterMean := averageClusterPowerHistory(clusterPowerHist)
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
log.Printf("Total power: %f, %d Sec Avg: %f", clusterPower, clusterPowerHist.Len(), clusterMean)
if clusterMean > hiThreshold {
log.Printf("Need to cap a node")
// 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
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
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
for _, victim := range victims {
@ -127,7 +128,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
if !cappedHosts[victim.Host] {
cappedHosts[victim.Host] = true
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 {
log.Print("Error capping host")
}

View file

@ -3,6 +3,7 @@ package pcp
import (
"bitbucket.org/sunybingcloud/elektron/constants"
"bitbucket.org/sunybingcloud/elektron/rapl"
"bitbucket.org/sunybingcloud/elektron/pcp"
"bitbucket.org/sunybingcloud/elektron/utilities"
"bufio"
"container/ring"
@ -110,16 +111,16 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, pref
powerHistories[host].Value = power
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
}
clusterPower := totalPower * RAPLUnits
clusterPower := totalPower * pcp.RAPLUnits
clusterPowerHist.Value = clusterPower
clusterPowerHist = clusterPowerHist.Next()
clusterMean := averageClusterPowerHistory(clusterPowerHist)
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
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 victims to uncap: %v", orderCappedVictims)
// 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
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
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
newVictimFound := false