Skip to content

Commit 3c6919f

Browse files
committed
# This is a combination of 252 commits.
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
1 parent c8e724c commit 3c6919f

22 files changed

+453723
-8032
lines changed

examples/powermanger/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ Execute the following below **as a non-root user with sudo rights** using **bash
3636
```bash
3737
./examples/powermanger/setup_power_manager.sh;
3838

39-
go run ./examples/powermanger/experiment_1.go
39+
go run ./examples/powermanger/experiment_2.go
4040

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

49-
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
48+
----
49+
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
50+
51+
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
5052

5153
2. Clean Up
5254
```bash
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
package main
2+
3+
import (
4+
"encoding/csv"
5+
"fmt"
6+
"os"
7+
"os/exec"
8+
"strconv"
9+
"sync"
10+
"time"
11+
12+
)
13+
14+
func setPowerProfileToNodes(freq1 int64, freq2 int64) error {
15+
fmt.Printf("node1:%d, node2:%d\n", freq1, freq2)
16+
// powerConfig
17+
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")
18+
cmd := exec.Command("bash", "-c", command)
19+
_, err := cmd.CombinedOutput()
20+
if err != nil {
21+
return err
22+
}
23+
//fmt.Println(string(output))
24+
25+
// performanceProfile w freq
26+
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)
27+
cmd = exec.Command("bash", "-c", command)
28+
_, err = cmd.CombinedOutput()
29+
if err != nil {
30+
return err
31+
}
32+
33+
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)
34+
cmd = exec.Command("bash", "-c", command)
35+
_, err = cmd.CombinedOutput()
36+
if err != nil {
37+
return err
38+
}
39+
//fmt.Println(string(output))
40+
41+
// apply to node
42+
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")
43+
cmd = exec.Command("bash", "-c", command)
44+
_, err = cmd.CombinedOutput()
45+
if err != nil {
46+
return err
47+
}
48+
49+
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")
50+
cmd = exec.Command("bash", "-c", command)
51+
_, err = cmd.CombinedOutput()
52+
if err != nil {
53+
return err
54+
}
55+
//fmt.Println(string(output))
56+
return nil
57+
}
58+
59+
func spinning(wg *sync.WaitGroup, resultChan chan int64) {
60+
defer wg.Done()
61+
62+
url := "aes-python.default.192.168.1.240.sslip.io"
63+
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)
64+
65+
startInvoke := time.Now().UTC().UnixMilli()
66+
cmd := exec.Command("bash", "-c", command)
67+
_, err := cmd.CombinedOutput()
68+
if err != nil {
69+
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
70+
return
71+
}
72+
endInvoke := time.Now().UTC().UnixMilli()
73+
latency := endInvoke-startInvoke
74+
resultChan <- latency
75+
fmt.Println(latency)
76+
return
77+
}
78+
79+
func sleeping(wg *sync.WaitGroup, resultChan chan int64) {
80+
defer wg.Done()
81+
82+
url := "auth-python.default.192.168.1.240.sslip.io"
83+
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)
84+
85+
startInvoke := time.Now().UTC().UnixMilli()
86+
cmd := exec.Command("bash", "-c", command)
87+
_, err := cmd.CombinedOutput()
88+
if err != nil {
89+
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
90+
return
91+
}
92+
endInvoke := time.Now().UTC().UnixMilli()
93+
latency := endInvoke-startInvoke
94+
resultChan <- latency
95+
fmt.Println(latency)
96+
return
97+
}
98+
99+
func main() {
100+
file, err := os.Create("metrics.csv")
101+
if err != nil {
102+
panic(err)
103+
}
104+
defer file.Close()
105+
106+
writer1 := csv.NewWriter(file)
107+
defer writer1.Flush()
108+
109+
err = writer1.Write(append([]string{"startTime", "endTime", "spinningLatency", "sleepingLatency"}))
110+
if err != nil {
111+
fmt.Printf("Error writing metrics to the CSV file: %v\n", err)
112+
}
113+
114+
// frequencies := [][]int64{{1200,1200},{1200,2400},{2400,2400}}
115+
// for i := 0; i < len(frequencies); i++ {
116+
// err := setPowerProfileToNodes(frequencies[i][0], frequencies[i][1])
117+
// if err != nil {
118+
// fmt.Printf(fmt.Sprintf("ERR1 :%+v", err))
119+
// }
120+
121+
now := time.Now()
122+
for time.Since(now) < (time.Minute*2) {
123+
// Create channels to receive results from goroutines
124+
spinningResultChan := make(chan int64)
125+
sleepingResultChan := make(chan int64)
126+
127+
startInvoke := time.Now().UTC().UnixMilli()
128+
go func() {
129+
url := "auth-python.default.192.168.1.240.sslip.io"
130+
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)
131+
132+
startInvoke := time.Now().UTC().UnixMilli()
133+
cmd := exec.Command("bash", "-c", command)
134+
_, err := cmd.CombinedOutput()
135+
if err != nil {
136+
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
137+
return
138+
}
139+
endInvoke := time.Now().UTC().UnixMilli()
140+
latency := endInvoke-startInvoke
141+
sleepingResultChan <- latency
142+
}()
143+
144+
go func() {
145+
url := "aes-python.default.192.168.1.240.sslip.io"
146+
command := fmt.Sprintf("cd $HOME/vSwarm/tools/test-client && ./test-client --addr %s:80 --name \"allow\"", url)
147+
148+
startInvoke := time.Now().UTC().UnixMilli()
149+
cmd := exec.Command("bash", "-c", command)
150+
_, err := cmd.CombinedOutput()
151+
if err != nil {
152+
fmt.Printf(fmt.Sprintf("ERR2: %+v", err))
153+
return
154+
}
155+
endInvoke := time.Now().UTC().UnixMilli()
156+
latency := endInvoke-startInvoke
157+
spinningResultChan <- latency
158+
}()
159+
160+
endInvoke := time.Now().UTC().UnixMilli()
161+
spinningLatency := <-spinningResultChan
162+
sleepingLatency := <-sleepingResultChan
163+
err = writer1.Write(append([]string{strconv.FormatInt(startInvoke, 10), strconv.FormatInt(endInvoke, 10), strconv.FormatInt(spinningLatency, 10), strconv.FormatInt(sleepingLatency, 10)}))
164+
if err != nil {
165+
fmt.Printf("Error writing metrics to the CSV file: %v\n", err)
166+
}
167+
}
168+
169+
err = writer1.Write(append([]string{"-","-","-","-"}))
170+
if err != nil {
171+
fmt.Printf("Error writing metrics to the CSV file: %v\n", err)
172+
}
173+
fmt.Println("done")
174+
// }
175+
}
Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
kubectl apply -f - <<EOF
12
apiVersion: "power.intel.com/v1"
23
kind: PowerConfig
34
metadata:
@@ -6,7 +7,30 @@ metadata:
67
spec:
78
# Add labels here for the Nodes you want the PowerNodeAgent to be applied to
89
powerNodeSelector:
9-
kubernetes.io/hostname: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
10+
kubernetes.io/os: linux
1011
# Add wanted PowerProfiles here; valid entries are as follows: performance, balance-performance, balance-power
1112
powerProfiles:
12-
- "performance"
13+
- "performance"
14+
EOF
15+
16+
kubectl apply -f - <<EOF
17+
apiVersion: v1
18+
kind: Pod
19+
metadata:
20+
name: example-power-pod
21+
spec:
22+
containers:
23+
- name: example-power-container
24+
image: ubuntu
25+
command: [ "/bin/sh" ]
26+
args: [ "-c", "sleep 15000" ]
27+
resources:
28+
requests:
29+
memory: "200Mi"
30+
cpu: "20"
31+
power.intel.com/perfomance-node1: "2"
32+
limits:
33+
memory: "200Mi"
34+
cpu: "2"
35+
power.intel.com/perfomance-node1: "2"
36+
EOF

examples/powermanger/setup_power_manager.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,4 @@ kubectl apply -f $HOME/vhive/examples/powermanger/shared-profile.yaml
5858
kubectl apply -f $HOME/vhive/examples/powermanger/shared-workload.yaml
5959

6060
kubectl get powerprofiles -n intel-power
61-
kubectl get powerworkloads -n intel-power
62-
63-
# Add prometheus
64-
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
65-
helm repo update
66-
helm install prometheus prometheus-community/kube-prometheus-stack
67-
kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090
61+
kubectl get powerworkloads -n intel-power
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
kubectl apply -f - <<EOF
2-
apiVersion: "power.intel.com/v1"
2+
apiVersion: power.intel.com/v1
33
kind: PowerProfile
44
metadata:
5-
name: performance
5+
name: shared-node1
66
namespace: intel-power
77
spec:
8-
name: "performance"
9-
max: 3400
10-
min: 3400
11-
shared: true
12-
governor: "performance"
8+
name: "shared-node1"
9+
max: 1500
10+
min: 1500
11+
shared: true
12+
governor: "powersave"
13+
EOF
14+
15+
kubectl apply -f - <<EOF
16+
apiVersion: power.intel.com/v1
17+
kind: PowerProfile
18+
metadata:
19+
name: shared-node2
20+
namespace: intel-power
21+
spec:
22+
name: "shared-node2"
23+
max: 2500
24+
min: 2500
25+
shared: true
26+
governor: "powersave"
1327
EOF

examples/powermanger/shared-workload.yaml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,42 @@ kubectl apply -f - <<EOF
22
apiVersion: "power.intel.com/v1"
33
kind: PowerWorkload
44
metadata:
5-
name: performance-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload
5+
name: shared-node1-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload
66
namespace: intel-power
77
spec:
8-
name: "performance-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload"
8+
name: "shared-node1-node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload"
99
allCores: true
1010
powerNodeSelector:
1111
kubernetes.io/hostname: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
12-
powerProfile: "performance"
13-
EOF
12+
powerProfile: "shared-node1"
13+
EOF
14+
15+
kubectl apply -f - <<EOF
16+
apiVersion: "power.intel.com/v1"
17+
kind: PowerWorkload
18+
metadata:
19+
name: shared-node-2-node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload
20+
namespace: intel-power
21+
spec:
22+
name: "shared-node2-node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us-workload"
23+
allCores: true
24+
powerNodeSelector:
25+
kubernetes.io/hostname: node-2.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
26+
powerProfile: "shared-node2"
27+
EOF
28+
29+
kubectl apply -f - <<EOF
30+
apiVersion: power.intel.com/v1
31+
kind: PowerNode
32+
metadata:
33+
name: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
34+
namespace: intel-power
35+
spec:
36+
nodeName: node-1.kt-cluster.ntu-cloud-pg0.utah.cloudlab.us
37+
powerProfiles:
38+
shared-node1: 1500000 || 1500000 ||
39+
powerWorkloads:
40+
shared-node1: shared-node1 ||
41+
sharedPool: shared-node1 || 1500000 || 1500000 || 2-19
42+
unaffectedCores: 0-1
43+
EOF

0 commit comments

Comments
 (0)