Skip to content

Commit

Permalink
# This is a combination of 252 commits.
Browse files Browse the repository at this point in the history
parent 6674807
author HermioneKT <[email protected]> 1706694164 +0800
committer HermioneKT <[email protected]> 1706694164 +0800

test

# This is the commit message #157:

test

# This is the commit message #159:

test

# This is the commit message #160:

test

# This is the commit message #161:

test

# This is the commit message #162:

test

# This is the commit message #163:

test

# This is the commit message #164:

tesT

# This is the commit message #165:

test

# This is the commit message #166:

test

# This is the commit message #167:

test

# This is the commit message #168:

test

# This is the commit message #169:

test

# This is the commit message #170:

test

# This is the commit message #171:

Test

# This is the commit message #172:

test

# This is the commit message #173:

test

# This is the commit message #174:

test

# This is the commit message #175:

test

# This is the commit message #176:

test

# This is the commit message #177:

test

# This is the commit message #178:

test

# This is the commit message #179:

test

# This is the commit message #180:

test

# This is the commit message #181:

test

# This is the commit message #182:

test

# This is the commit message #183:

test

# This is the commit message #184:

test

# This is the commit message #185:

test

# This is the commit message #186:

test

# This is the commit message #187:

test

# This is the commit message #188:

test

# This is the commit message #189:

test

# This is the commit message #190:

Test

# This is the commit message #191:

Test

# This is the commit message #192:

test

# This is the commit message #193:

Test

# This is the commit message #194:

test

# This is the commit message #195:

test

# This is the commit message #196:

test

# This is the commit message #197:

test

# This is the commit message #198:

test

# This is the commit message #199:

Test

# This is the commit message #200:

test

# This is the commit message #201:

test

# This is the commit message #202:

Test

# This is the commit message #203:

test

# This is the commit message #204:

test

# This is the commit message #205:

test

# This is the commit message #206:

test

# This is the commit message #207:

test

# This is the commit message #208:

test

# This is the commit message #209:

test

# This is the commit message #210:

test

# This is the commit message #211:

Test

# This is the commit message #212:

test

# This is the commit message #213:

Test

# This is the commit message #214:

Test

# This is the commit message #215:

Test

# This is the commit message #216:

test

# This is the commit message #217:

Test

# This is the commit message #218:

test

# This is the commit message #219:

test

# This is the commit message #220:

test

# This is the commit message #221:

test

# This is the commit message #222:

test

# This is the commit message #223:

test

# This is the commit message #224:

test

# This is the commit message #225:

test

# This is the commit message #226:

test

# This is the commit message #227:

test

# This is the commit message #228:

test

# This is the commit message #229:

Test

# This is the commit message #230:

test

# This is the commit message #231:

test

# This is the commit message #232:

test

# This is the commit message #233:

test

# This is the commit message #234:

Test

# This is the commit message #235:

test

# This is the commit message #236:

test

# This is the commit message #237:

test

# This is the commit message #238:

test

# This is the commit message #239:

test

# This is the commit message #240:

test

# This is the commit message #241:

test

# This is the commit message #242:

test

# This is the commit message #243:

test

# This is the commit message #244:

test

# This is the commit message #245:

test

# This is the commit message #246:

test

# This is the commit message #247:

test

# This is the commit message #248:

test

# This is the commit message #249:

test

# This is the commit message #250:

test

# This is the commit message #251:

test

# This is the commit message #252:

test
  • Loading branch information
HermioneKT committed Jan 31, 2024
1 parent c8e724c commit 3c6919f
Show file tree
Hide file tree
Showing 22 changed files with 453,723 additions and 8,032 deletions.
8 changes: 5 additions & 3 deletions examples/powermanger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ Execute the following below **as a non-root user with sudo rights** using **bash
```bash
./examples/powermanger/setup_power_manager.sh;

go run ./examples/powermanger/experiment_1.go
go run ./examples/powermanger/experiment_2.go

while true; do current_time=$(date -u +%s%3N); cpu_average=$(grep 'MHz' /proc/cpuinfo | awk '{ total += $4 } END { print total / NR }'); echo "${current_time}: ${cpu_average}" >> memory.txt; sleep 0.01; done

while true; do
current_time=$(date -u +%s%3N)
sudo perf stat -e instructions,cycles -I 1000 -o perf_output.data sleep 1
ipc=$(grep -E '(instructions|cycles)' perf_output.data | awk '{ total += $1 } END { if (total) print total / 2 }')
echo "${current_time}: ${ipc}" >> ipc_results1.txt; done

while true; do current_time=$(date -u +%s%3N); stats=$(sudo turbostat --Summary --quiet --show Busy%,Avg_MHz,PkgWatt); echo "${current_time}, $stats" >> $output_file; sleep 0.01; done
----
while true; do current_time=$(date -u +%s%3N); cpu_average=$(grep 'MHz' /proc/cpuinfo | awk '{ total += $4 } END { print total / NR }'); echo "${current_time}: ${cpu_average}" >> node2_freq.txt; sleep 0.01; done

sudo turbostat --quiet --interval 1 --show PkgWatt | while read line; do if [[ ! $line =~ PkgWatt ]]; then timestamp=$(date +%s%3N); echo "$timestamp: $line"; fi; done >> node2_power.txt

2. Clean Up
```bash
Expand Down
175 changes: 175 additions & 0 deletions examples/powermanger/experiment_2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
package main

import (
"encoding/csv"
"fmt"
"os"
"os/exec"
"strconv"
"sync"
"time"

)

func setPowerProfileToNodes(freq1 int64, freq2 int64) error {
fmt.Printf("node1:%d, node2:%d\n", freq1, freq2)
// powerConfig
command := fmt.Sprintf("kubectl apply -f - <<EOF\napiVersion: \"power.intel.com/v1\"\nkind: PowerConfig\nmetadata:\n name: power-config\n namespace: intel-power\nspec:\n powerNodeSelector:\n kubernetes.io/os: linux\n powerProfiles:\n - \"performance\"\nEOF")
cmd := exec.Command("bash", "-c", command)
_, err := cmd.CombinedOutput()
if err != nil {
return err
}
//fmt.Println(string(output))

// performanceProfile w freq
command = fmt.Sprintf("kubectl apply -f - <<EOF\napiVersion: \"power.intel.com/v1\"\nkind: PowerProfile\nmetadata:\n name: performance-node1\n namespace: intel-power\nspec:\n name: \"performance-node1\"\n max: %d\n min: %d\n shared: true\n governor: \"performance\"\nEOF", freq1, freq1)
cmd = exec.Command("bash", "-c", command)
_, err = cmd.CombinedOutput()
if err != nil {
return err
}

command = fmt.Sprintf("kubectl apply -f - <<EOF\napiVersion: \"power.intel.com/v1\"\nkind: PowerProfile\nmetadata:\n name: performance-node2\n namespace: intel-power\nspec:\n name: \"performance-node2\"\n max: %d\n min: %d\n shared: true\n governor: \"performance\"\nEOF", freq2, freq2)
cmd = exec.Command("bash", "-c", command)
_, err = cmd.CombinedOutput()
if err != nil {
return err
}
//fmt.Println(string(output))

// apply to node
command = fmt.Sprintf("kubectl apply -f - <<EOF\napiVersion: \"power.intel.com/v1\"\nkind: PowerWorkload\nmetadata:\n name: performance-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload\n namespace: intel-power\nspec:\n name: \"performance-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload\"\n allCores: true\n powerNodeSelector:\n kubernetes.io/hostname: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us\n powerProfile: \"performance-node1\"\nEOF")
cmd = exec.Command("bash", "-c", command)
_, err = cmd.CombinedOutput()
if err != nil {
return err
}

command = fmt.Sprintf("kubectl apply -f - <<EOF\napiVersion: \"power.intel.com/v1\"\nkind: PowerWorkload\nmetadata:\n name: performance-node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload\n namespace: intel-power\nspec:\n name: \"performance-node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload\"\n allCores: true\n powerNodeSelector:\n kubernetes.io/hostname: node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us\n powerProfile: \"performance-node2\"\nEOF")
cmd = exec.Command("bash", "-c", command)
_, err = cmd.CombinedOutput()
if err != nil {
return err
}
//fmt.Println(string(output))
return nil
}

func spinning(wg *sync.WaitGroup, resultChan chan int64) {
defer wg.Done()

url := "aes-python.default.192.168.1.240.sslip.io"
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)

startInvoke := time.Now().UTC().UnixMilli()
cmd := exec.Command("bash", "-c", command)
_, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
return
}
endInvoke := time.Now().UTC().UnixMilli()
latency := endInvoke-startInvoke
resultChan <- latency
fmt.Println(latency)
return
}

func sleeping(wg *sync.WaitGroup, resultChan chan int64) {
defer wg.Done()

url := "auth-python.default.192.168.1.240.sslip.io"
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)

startInvoke := time.Now().UTC().UnixMilli()
cmd := exec.Command("bash", "-c", command)
_, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
return
}
endInvoke := time.Now().UTC().UnixMilli()
latency := endInvoke-startInvoke
resultChan <- latency
fmt.Println(latency)
return
}

func main() {
file, err := os.Create("metrics.csv")
if err != nil {
panic(err)
}
defer file.Close()

writer1 := csv.NewWriter(file)
defer writer1.Flush()

err = writer1.Write(append([]string{"startTime", "endTime", "spinningLatency", "sleepingLatency"}))
if err != nil {
fmt.Printf("Error writing metrics to the CSV file: %v\n", err)
}

// frequencies := [][]int64{{1200,1200},{1200,2400},{2400,2400}}
// for i := 0; i < len(frequencies); i++ {
// err := setPowerProfileToNodes(frequencies[i][0], frequencies[i][1])
// if err != nil {
// fmt.Printf(fmt.Sprintf("ERR1 :%+v", err))
// }

now := time.Now()
for time.Since(now) < (time.Minute*2) {
// Create channels to receive results from goroutines
spinningResultChan := make(chan int64)
sleepingResultChan := make(chan int64)

startInvoke := time.Now().UTC().UnixMilli()
go func() {
url := "auth-python.default.192.168.1.240.sslip.io"
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)

startInvoke := time.Now().UTC().UnixMilli()
cmd := exec.Command("bash", "-c", command)
_, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
return
}
endInvoke := time.Now().UTC().UnixMilli()
latency := endInvoke-startInvoke
sleepingResultChan <- latency
}()

go func() {
url := "aes-python.default.192.168.1.240.sslip.io"
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)

startInvoke := time.Now().UTC().UnixMilli()
cmd := exec.Command("bash", "-c", command)
_, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
return
}
endInvoke := time.Now().UTC().UnixMilli()
latency := endInvoke-startInvoke
spinningResultChan <- latency
}()

endInvoke := time.Now().UTC().UnixMilli()
spinningLatency := <-spinningResultChan
sleepingLatency := <-sleepingResultChan
err = writer1.Write(append([]string{strconv.FormatInt(startInvoke, 10), strconv.FormatInt(endInvoke, 10), strconv.FormatInt(spinningLatency, 10), strconv.FormatInt(sleepingLatency, 10)}))
if err != nil {
fmt.Printf("Error writing metrics to the CSV file: %v\n", err)
}
}

err = writer1.Write(append([]string{"-","-","-","-"}))
if err != nil {
fmt.Printf("Error writing metrics to the CSV file: %v\n", err)
}
fmt.Println("done")
// }
}
28 changes: 26 additions & 2 deletions examples/powermanger/powerconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
kubectl apply -f - <<EOF
apiVersion: "power.intel.com/v1"
kind: PowerConfig
metadata:
Expand All @@ -6,7 +7,30 @@ metadata:
spec:
# Add labels here for the Nodes you want the PowerNodeAgent to be applied to
powerNodeSelector:
kubernetes.io/hostname: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
kubernetes.io/os: linux
# Add wanted PowerProfiles here; valid entries are as follows: performance, balance-performance, balance-power
powerProfiles:
- "performance"
- "performance"
EOF

kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
name: example-power-pod
spec:
containers:
- name: example-power-container
image: ubuntu
command: [ "/bin/sh" ]
args: [ "-c", "sleep 15000" ]
resources:
requests:
memory: "200Mi"
cpu: "20"
power.intel.com/perfomance-node1: "2"
limits:
memory: "200Mi"
cpu: "2"
power.intel.com/perfomance-node1: "2"
EOF
8 changes: 1 addition & 7 deletions examples/powermanger/setup_power_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,4 @@ kubectl apply -f $HOME/vhive/examples/powermanger/shared-profile.yaml
kubectl apply -f $HOME/vhive/examples/powermanger/shared-workload.yaml

kubectl get powerprofiles -n intel-power
kubectl get powerworkloads -n intel-power

# Add prometheus
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack
kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090
kubectl get powerworkloads -n intel-power
28 changes: 21 additions & 7 deletions examples/powermanger/shared-profile.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
kubectl apply -f - <<EOF
apiVersion: "power.intel.com/v1"
apiVersion: power.intel.com/v1
kind: PowerProfile
metadata:
name: performance
name: shared-node1
namespace: intel-power
spec:
name: "performance"
max: 3400
min: 3400
shared: true
governor: "performance"
name: "shared-node1"
max: 1500
min: 1500
shared: true
governor: "powersave"
EOF

kubectl apply -f - <<EOF
apiVersion: power.intel.com/v1
kind: PowerProfile
metadata:
name: shared-node2
namespace: intel-power
spec:
name: "shared-node2"
max: 2500
min: 2500
shared: true
governor: "powersave"
EOF
38 changes: 34 additions & 4 deletions examples/powermanger/shared-workload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,42 @@ kubectl apply -f - <<EOF
apiVersion: "power.intel.com/v1"
kind: PowerWorkload
metadata:
name: performance-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload
name: shared-node1-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload
namespace: intel-power
spec:
name: "performance-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload"
name: "shared-node1-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload"
allCores: true
powerNodeSelector:
kubernetes.io/hostname: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
powerProfile: "performance"
EOF
powerProfile: "shared-node1"
EOF

kubectl apply -f - <<EOF
apiVersion: "power.intel.com/v1"
kind: PowerWorkload
metadata:
name: shared-node-2-node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload
namespace: intel-power
spec:
name: "shared-node2-node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload"
allCores: true
powerNodeSelector:
kubernetes.io/hostname: node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
powerProfile: "shared-node2"
EOF

kubectl apply -f - <<EOF
apiVersion: power.intel.com/v1
kind: PowerNode
metadata:
name: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
namespace: intel-power
spec:
nodeName: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
powerProfiles:
shared-node1: 1500000 || 1500000 ||
powerWorkloads:
shared-node1: shared-node1 ||
sharedPool: shared-node1 || 1500000 || 1500000 || 2-19
unaffectedCores: 0-1
EOF
Loading

0 comments on commit 3c6919f

Please sign in to comment.