Skip to content

Commit

Permalink
Fix perf
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Nov 4, 2023
1 parent 2230db2 commit d24c9a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
23 changes: 21 additions & 2 deletions performance_measurement/measure_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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
6 changes: 3 additions & 3 deletions performance_measurement/zk_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d24c9a6

Please sign in to comment.