Merge branch 'master' of https://bitbucket.org/sunybingcloud/electron into classMapWattsCommandLine

This commit is contained in:
Pradyumna Kaushik 2017-02-05 15:05:17 -05:00
commit faad66f78c

View file

@ -17,7 +17,7 @@ import (
var RAPLUnits = math.Pow(2, -32) var RAPLUnits = math.Pow(2, -32)
func meanPKG(history *ring.Ring) float64 { func averageNodePowerHistory(history *ring.Ring) float64 {
total := 0.0 total := 0.0
count := 0.0 count := 0.0
@ -33,12 +33,13 @@ func meanPKG(history *ring.Ring) float64 {
return 0.0 return 0.0
} }
count /= 2 count /= 4 // two PKGs, two DRAM for all nodes currently
return (total / count) return (total / count)
} }
func meanCluster(history *ring.Ring) float64 { // TODO: Figure a way to merge this and avgpower
func averageClusterPowerHistory(history *ring.Ring) float64 {
total := 0.0 total := 0.0
count := 0.0 count := 0.0
@ -95,14 +96,19 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
indexToHost := make(map[int]string) indexToHost := make(map[int]string)
for i, hostMetric := range headers { for i, hostMetric := range headers {
split := strings.Split(hostMetric, ":") metricSplit := strings.Split(hostMetric, ":")
//log.Printf("%d Host %s: Metric: %s\n", i, split[0], split[1]) //log.Printf("%d Host %s: Metric: %s\n", i, split[0], split[1])
if strings.Contains(split[1], "RAPL_ENERGY_PKG") { if strings.Contains(metricSplit[1], "RAPL_ENERGY_PKG") ||
strings.Contains(metricSplit[1], "RAPL_ENERGY_DRAM") {
//fmt.Println("Index: ", i) //fmt.Println("Index: ", i)
powerIndexes = append(powerIndexes, i) powerIndexes = append(powerIndexes, i)
indexToHost[i] = split[0] indexToHost[i] = metricSplit[0]
powerHistories[split[0]] = ring.New(10) // Two PKGS per node, 10 = 5 seconds tracking
// Only create one ring per host
if _, ok := powerHistories[metricSplit[0]]; !ok {
powerHistories[metricSplit[0]] = ring.New(20) // Two PKGS, two DRAM per node, 20 = 5 seconds of tracking
}
} }
} }
@ -139,7 +145,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
clusterPowerHist.Value = clusterPower clusterPowerHist.Value = clusterPower
clusterPowerHist = clusterPowerHist.Next() clusterPowerHist = clusterPowerHist.Next()
clusterMean := meanCluster(clusterPowerHist) clusterMean := 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)
@ -151,10 +157,10 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, prefix s
// 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 := meanPKG(history) histMean := 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, Victim{Watts: histMean, Host: name})
//log.Printf("host: %s, Avg: %f", name, histMean * RAPLUnits)
} }
sort.Sort(VictimSorter(victims)) // Sort by average wattage sort.Sort(VictimSorter(victims)) // Sort by average wattage