Skip to content

Commit 15ab28d

Browse files
dklylegrahamwhaley
authored andcommitted
fixing indexing, start with 0
1 parent 85fe594 commit 15ab28d

File tree

1 file changed

+45
-40
lines changed

1 file changed

+45
-40
lines changed

metrics/report/report_dockerfile/scaling.R

+45-40
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,27 @@ for (currentdir in resultdirs) {
5757
testname=datasetname
5858

5959
cdata=data.frame(boot_time=as.numeric(fdata$BootResults$launch_time$Result)/1000)
60+
cdata=cbind(cdata, num_pods=as.numeric(fdata$BootResults$n_pods$Result))
6061

6162
# format the utilization data
6263
udata=data.frame(nodename=fdata$BootResults$node_util)
6364
for (i in seq(length(cdata[, "boot_time"]))) {
65+
num_pods=fdata$BootResults$n_pods$Result[i]
66+
index=i-1
6467
if (i == 1) {
6568
# first iteration provide column name for c1
6669
c1=cbind(node=udata$nodename.node)
67-
c2=cbind(udata$nodename.noschedule)
68-
c3=cbind(udata$nodename.cpu_idle$Result)
69-
c4=cbind(udata$nodename.mem_free$Result)/(1024*1024)
70-
c5=cbind(rep(i, length(udata$nodename.node)))
71-
c6=cbind(rep(testname, length(udata$nodename.node)))
70+
c2=cbind(noschedule=udata$nodename.noschedule)
71+
c3=cbind(cpu_idle=udata$nodename.cpu_idle$Result)
72+
c4=cbind(mem_free=udata$nodename.mem_free$Result)/(1024*1024)
73+
# using index to make chart start with 0 rather than 1
74+
c5=cbind(pod=rep(num_pods, length(udata$nodename.node)))
75+
c6=cbind(testname=rep(testname, length(udata$nodename.node)))
7276
# declare formatted utility data
7377
fudata=cbind(c1,c2,c3,c4,c5,c6)
7478
}
7579
else {
7680
# shift to 0 based indexing
77-
index=i-1
7881
sindex=(index*4)+1
7982
eindex=sindex+3
8083
# grab 3 columns for next row bind
@@ -83,14 +86,14 @@ for (currentdir in resultdirs) {
8386
c2=cbind(row[,2])
8487
c3=cbind(row[,3]$Result)
8588
c4=cbind(row[,4]$Result)/(1024*1024)
86-
c5=cbind(rep(i, length(udata$nodename.node)))
89+
# using index to make chart start with 0 rather than 1
90+
c5=cbind(rep(num_pods, length(udata$nodename.node)))
8791
c6=cbind(rep(testname, length(udata$nodename.node)))
8892
# create the new row (which is actually the number of nodes of rows)
8993
frow=cbind(c1,c2,c3,c4,c5,c6)
9094
fudata=rbind(fudata,frow)
9195
}
9296
}
93-
colnames(fudata)=c("node", "noschedule", "cpu_idle", "mem_free", "pod", "testname")
9497
# fudata is considered a vector for some reason so converting it to a data.frame
9598
fudata=as.data.frame(fudata)
9699
# get unique node names
@@ -113,44 +116,43 @@ for (currentdir in resultdirs) {
113116

114117
# format the pod data from 2 nested columns in a series
115118
# of index specific columns to just 2 columns
116-
pdata=data.frame(fdata$BootResults$launched_pods)
119+
# omitting the first row as it is the baseline and contains
120+
# NA values for launched pods as there were none. If we don't
121+
# omit the first row, this will throw a warning, but notice that it
122+
# makes the index funky below
123+
pdata=data.frame(fdata$BootResults$launched_pods[-1])
117124
pudata=c()
118-
for (i in seq(length(cdata[, "boot_time"]))) {
119-
if (i == 1) {
120-
# there are no valid values for this index, skipping
121-
next
122-
}
123-
else {
124-
# shift to 0 based indexing
125-
index=i-1
126-
sindex=(index*2)+1
127-
eindex=sindex+1
128-
row=cbind(pdata[,sindex:eindex])
129-
c1=cbind(podname=row[,1])
130-
c2=cbind(node=row[,2])
131-
c3=cbind(count=rep(i, length(pdata$pod_name)))
132-
c4=cbind(boot_time=rep(cdata[, "boot_time"][i],length(pdata$pod_name)))
133-
c5=cbind(dataset=rep(testname, length(pdata$pod_name)))
134-
prow=cbind(c1,c2,c3,c4,c5)
135-
pudata=rbind(pudata,prow)
136-
}
125+
# pdata is 1 row shorter than cdata, hence the subtract 1
126+
for (i in seq(length(cdata[, "boot_time"]) - 1)) {
127+
# using i+1 rather than i to account for the missing row when indexing in to fdata
128+
num_pods=fdata$BootResults$n_pods$Result[i+1]
129+
# shift to 0 based indexing for pdata, so we can iterate through the generated named columns
130+
index=i-1
131+
sindex=(index*2)+1
132+
eindex=sindex+1
133+
row=cbind(pdata[,sindex:eindex])
134+
c1=cbind(podname=row[,1])
135+
c2=cbind(node=row[,2])
136+
c3=cbind(count=rep(num_pods, length(pdata$pod_name)))
137+
# using i+1 rather than i to account for the missing row when indexing in to cdata
138+
c4=cbind(boot_time=rep(cdata[, "boot_time"][i+1],length(pdata$pod_name)))
139+
c5=cbind(dataset=rep(testname, length(pdata$pod_name)))
140+
prow=cbind(c1,c2,c3,c4,c5)
141+
pudata=rbind(pudata,prow)
137142
}
138143
# pndata is considered a vector for some reason so converting it to a data.frame
139144
pudata=as.data.frame(pudata)
140145
pudata$count=as.numeric(as.character(pudata$count))
141146
pudata$boot_time=as.numeric(as.character(pudata$boot_time))
142147

143-
cdata=cbind(cdata, count=seq_len(length(cdata[, "boot_time"])))
148+
# using 0 based index rather than starting with 1
144149
cdata=cbind(cdata, testname=rep(testname, length(cdata[, "boot_time"]) ))
145150
cdata=cbind(cdata, dataset=rep(datasetname, length(cdata[, "boot_time"]) ))
146151

147152
# Gather our statistics
148153
# '-1' containers, as the first entry should be a data capture of before
149154
# the first container was run.
150-
# FIXME - once the test starts to store a stats baseline in slot 0, then
151-
# we should re-enable the '-1'
152-
#sdata=data.frame(num_containers=length(cdata[, "avail_gb"])-1)
153-
sdata=data.frame(num_containers=length(cdata[, "boot_time"]))
155+
sdata=data.frame(num_pods=as.numeric(as.character(cdata[, "num_pods"][length(cdata[, "num_pods"])])))
154156
sudata=c()
155157
# first (which should be 0-containers)
156158
for (nodename in nodes) {
@@ -169,10 +171,13 @@ for (currentdir in resultdirs) {
169171
as.numeric(as.character(cdata[, node_cpu_idle][length(cdata[, node_cpu_idle])])))
170172
sudata=rbind(sudata, srdata)
171173
}
174+
175+
# now that we have sudata, perform the calculations
176+
total_pods=as.numeric(as.character(cdata[, "num_pods"][length(cdata[, "num_pods"])]))
172177
sdata=cbind(sdata, mem_consumed=sum(sudata[, "mem_consumed"]))
173178
sdata=cbind(sdata, cpu_consumed=sum(sudata[, "cpu_consumed"]))
174179
sdata=cbind(sdata, boot_time=cdata[, "boot_time"][length(cdata[, "boot_time"])])
175-
sdata=cbind(sdata, avg_gb_per_c=sdata$mem_consumed / sdata$num_containers)
180+
sdata=cbind(sdata, avg_gb_per_c=sdata$mem_consumed / total_pods)
176181
sdata=cbind(sdata, runtime=testname)
177182

178183
# Store away as a single set
@@ -183,17 +188,17 @@ for (currentdir in resultdirs) {
183188

184189
ms = c(
185190
"Test"=testname,
186-
"n"=sdata$num_containers,
191+
"n"=total_pods,
187192
"size"=round((sdata$mem_consumed), 3),
188193
"gb/n"=round(sdata$avg_gb_per_c, digits=4),
189194
"n/Gb"= round(1 / sdata$avg_gb_per_c, digits=2)
190195
)
191196

192197
cs = c(
193198
"Test"=testname,
194-
"n"=sdata$num_containers,
199+
"n"=total_pods,
195200
"cpu"=round(sdata$cpu_consumed, digits=3),
196-
"cpu/n"=round((sdata$cpu_consumed / sdata$num_containers), digits=4)
201+
"cpu/n"=round((sdata$cpu_consumed / num_pods), digits=4)
197202
)
198203

199204
rstats=rbind(rstats, ms)
@@ -223,7 +228,7 @@ mem_stats_plot = suppressWarnings(ggtexttable(data.frame(rstats),
223228
mem_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
224229
as.numeric(as.character(mem_free)),
225230
colour=(if (num_test_runs > 1) testname else node),
226-
group=interaction(testname, node))) +
231+
group=interaction(testname, node))) +
227232
labs(colour=colour_label) +
228233
geom_line(alpha=0.2) +
229234
geom_point(aes(shape=node), alpha=0.3, size=0.5) +
@@ -240,7 +245,7 @@ cpu_stats_plot = suppressWarnings(ggtexttable(data.frame(cstats), theme=ttheme(b
240245
cpu_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
241246
as.numeric(as.character(cpu_idle)),
242247
colour=(if (num_test_runs > 1) testname else node),
243-
group=interaction(testname, node))) +
248+
group=interaction(testname, node))) +
244249
labs(colour=colour_label) +
245250
geom_line(alpha=0.2) +
246251
geom_point(aes(shape=node), alpha=0.3, size=0.5) +
@@ -252,7 +257,7 @@ cpu_line_plot <- ggplot(data=fndata, aes(as.numeric(as.character(pod)),
252257

253258
# Show how boot time changed
254259
boot_line_plot <- ggplot() +
255-
geom_line( data=data, aes(count, boot_time, colour=testname, group=dataset), alpha=0.2) +
260+
geom_line( data=data, aes(num_pods, boot_time, colour=testname, group=dataset), alpha=0.2) +
256261
geom_point( data=pndata, aes(count, boot_time, colour=interaction(dataset, node), group=dataset), alpha=0.6, size=0.6, stroke=0, shape=16) +
257262
xlab("pods") +
258263
ylab("Boot time (s)") +

0 commit comments

Comments
 (0)