From d24c9a6e805ff0dd290c5c8c00ae1433ab3a5eab Mon Sep 17 00:00:00 2001 From: Tyler Gu Date: Sat, 4 Nov 2023 17:06:08 -0500 Subject: [PATCH] Fix perf Signed-off-by: Tyler Gu --- .../measure_performance.py | 23 +++++++++++++++++-- performance_measurement/zk_inputs.py | 6 ++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/performance_measurement/measure_performance.py b/performance_measurement/measure_performance.py index 084554d62..f6dcd63c3 100644 --- a/performance_measurement/measure_performance.py +++ b/performance_measurement/measure_performance.py @@ -26,7 +26,7 @@ def load_inputs_from_dir(dir: str) -> list: inputs = [] - files = glob.glob(f"{dir}/mutated-*.yaml") + files = glob.glob(f"{dir}/input-*.yaml") files.sort() logging.info(f"Loading {len(files)} inputs from {dir}") for file in files: @@ -98,7 +98,7 @@ def load_inputs_from_dir(dir: str) -> list: crd = process_crd(kubernetes_client(kubeconfig, context_name), KubectlClient(kubeconfig, context_name), config.crd_name) - trial_dir = f"{args.workdir_path}/trial" + trial_dir = f"{args.workdir_path}/trial-normal" os.makedirs(trial_dir, exist_ok=True) runner = MeasurementRunner( namespace, crd, trial_dir, kubeconfig, context_name) @@ -117,4 +117,23 @@ def load_inputs_from_dir(dir: str) -> list: json.dump(dataclasses.asdict(measurement_result), f) gen += 1 + single_operation_trial_dir = f"{args.workdir_path}/trial-single-operation" + os.makedirs(single_operation_trial_dir, exist_ok=True) + runner = MeasurementRunner( + namespace, crd, single_operation_trial_dir, kubeconfig, context_name) + gen = 0 + workloads = load_inputs_from_dir(dir=f"{args.workdir_path}/inputs") + for workload in workloads: + cluster.restart_cluster(name="anvil", kubeconfig=kubeconfig) + deployed = deploy.deploy_with_retry(kubeconfig, context_name, namespace) + if not deployed: + logging.info('Not deployed. Try again!') + + measurement_result = runner.run( + workload, MeasurementRunner.wait_for_zk_spec, MeasurementRunner.wait_for_pod_ready, gen) + if measurement_result is not None: + measurement_result_file = f"{trial_dir}/measurement_result_{gen:03d}.json" + with open(measurement_result_file, "w") as f: + json.dump(dataclasses.asdict(measurement_result), f) + gen += 1 # collect the performance data diff --git a/performance_measurement/zk_inputs.py b/performance_measurement/zk_inputs.py index 46cc95fb8..a15bf60a7 100644 --- a/performance_measurement/zk_inputs.py +++ b/performance_measurement/zk_inputs.py @@ -28,11 +28,11 @@ def serialize(self, output_dir: str): if skip_input: continue - with open(os.path.join(output_dir, f'input-{index}.yaml'), 'w') as f: + with open(os.path.join(output_dir, f'input-{index:03d}.yaml'), 'w') as f: yaml.dump(input["input"], f) - with open(os.path.join(output_dir, f'zk-{index}.yaml'), 'w') as f: + with open(os.path.join(output_dir, f'zk-{index:03d}.yaml'), 'w') as f: yaml.dump(ZooKeeperInputGenerator.convert(input["input"]), f) - with open(os.path.join(output_dir, f'input-{index}.patch'), 'w') as f: + with open(os.path.join(output_dir, f'input-{index:03d}.patch'), 'w') as f: f.write(str(patch)) previous_input = input["input"] index += 1