in scheme_adapters/simple_rl_adapter/simple_rl_adapter.py [0:0]
def step(self,action):
action1, action2 = self.get_action(action)
scheme = str(action1) + "K \t max \t 0 \t 0 \t" + str(action2) + "s \t max \t pageout"
file_name = self.path + "/scheme_adapters/simple_rl_adapter/scheme"
scheme_file = open(file_name, "w")
scheme_file.write(scheme)
scheme_file.close()
subprocess.Popen(["sudo", "python3", self.damos_path, "schemes", "--schemes", file_name, self.pid])
subprocess.call(["sudo", "DAMOOS=" + self.path, "bash", self.path + "/frontend/wait_for_process.sh", self.pid])
subprocess.call(["sudo", "DAMOOS=" + self.path, "bash", self.path + "/frontend/wait_for_metric_collector.sh", self.pid, "runtime", "rss"])
subprocess.call(["sudo", "DAMOOS=" + self.path, "bash", self.path + "/frontend/get_metric.sh", self.pid, "runtime", "stat"])
fil1 = open(self.path + "/results/runtime/" + str(self.pid) + ".stat", "r")
runtime = float(str(fil1.readlines()).split("'")[1][0:-2])
print("runtime", runtime)
runtime_overhead = ((runtime - self.orig_runtime)/self.orig_runtime)*100
print("runtime_overhead", runtime_overhead)
subprocess.call(["sudo", "DAMOOS=" + self.path, "bash", self.path + "/frontend/get_metric.sh", self.pid, "rss", "full_avg"])
fil1 = open(self.path + "/results/rss/" + str(self.pid) + ".full_avg", "r")
rss = float(str(fil1.readlines()).split("'")[1][0:-2])
print("rss", rss)
rss_overhead=((rss - self.orig_rss)/self.orig_rss)*100
print("rss_overhead", rss_overhead)
score = -((rss_overhead)*0.5 + (runtime_overhead)*0.5)
print("score", score)
subprocess.call(["sudo", "DAMOOS=" + self.path, "bash", self.path + "/frontend/cleanup.sh"])
return np.array(score),np.array(int(rss_overhead)),True