From 2a9236fb81b350bab10501dc2f2146e1653a0a0f Mon Sep 17 00:00:00 2001 From: 0xFugue <119708655+0xFugue@users.noreply.github.com> Date: Fri, 1 Sep 2023 17:42:35 +0530 Subject: [PATCH] nolat runs --- build_cases.py | 47 -------------------------------------------- run.sh | 48 --------------------------------------------- scripts/analysis.py | 36 ++++++++++++++++++++++------------ 3 files changed, 23 insertions(+), 108 deletions(-) delete mode 100644 build_cases.py delete mode 100644 run.sh diff --git a/build_cases.py b/build_cases.py deleted file mode 100644 index 045d283..0000000 --- a/build_cases.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -import csv -import json -import random -import shutil -from build_config import build_config - -def build_case(overlay, committees, nodes, config_name, max_view=1, network='default'): - build_config(overlay, committees, nodes, config_name, max_view, network) - # rename the runs with same configs - if os.path.exists(f"../configs/{config_name}.json"): - tail = random.randint(1, 10000) - modified_name = f"{config_name}_{tail}" - os.rename(f"{config_name}.json", f"{modified_name}.json") - with open(f"{modified_name}.json", "r+") as f: - data = json.load(f) - data["stream_settings"]["path"] = f"{modified_name}.json" - f.seek(0) - json.dump(data, f) - f.truncate() - print((config_name, modified_name)) - config_name = modified_name - shutil.move(f"{config_name}.json", "../configs/") - -def build_cases(csv_path): - with open(csv_path, 'r') as csv_file: - reader = csv.reader(csv_file) - for row in reader: - overlay_type, node_count, committees, desc = row - if overlay_type == "overlay": - continue - config_name = f"{overlay_type}_{node_count}_{committees}" - # build_case(overlay_type, committees, node_count, f"{config_name}_view_1_default") - # build_case(overlay_type, committees, node_count, f"{config_name}_view_10_default", max_view="5") - # build_case(overlay_type, committees, node_count, f"{config_name}_view_10_optimistic", max_view="5", network="optimistic") - # build_case(overlay_type, committees, node_count, f"{config_name}_view_10_pessimistic", max_view="5", network="pessimistic") - build_case(overlay_type, committees, node_count, f"{config_name}_view_10_nolat", max_view="10", network="nolat") - -if __name__ == "__main__": - import sys - if len(sys.argv) != 2: - print("Usage: python generate_configs.py ") - sys.exit(1) - - csv_path = sys.argv[1] - build_cases(csv_path) - diff --git a/run.sh b/run.sh deleted file mode 100644 index 6cff076..0000000 --- a/run.sh +++ /dev/null @@ -1,48 +0,0 @@ - -#for i in "10 100 200 300 400 500 600 700 800 900 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000" -prefix="compare" -for p in 0.8 0.5 #0.1 0.01 0.001 0.0001 -do - dir="compare_"$p"/" - mkdir -p $dir - echo "overlay,nodes,committees_or_depth,description" > $dir$prefix"_"$p".csv" - for i in 10 50 100 250 500 #750 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 12000 1400 - do - python3 build_tests.py --num-nodes $i --failure-threshold $p >> $dir$prefix"_"$p".csv" - echo "num-nodes = $i, failure-threshold = $p" - done -done - - - -for p in 0.8 0.5 0.1 0.01 0.001 0.0001 -do - dir="compare_"$p"/" - cd $dir - mkdir configs output scripts - cp ../*.py scripts - cd scripts - ln -s ../../config_builder/ - python3 build_cases.py ../$prefix"_"$p".csv" - cd .. - python3 scripts/run_configs.py configs/ - rm -rf scripts - cd .. - echo "config gen ($p) done.." -done - - - -for p in 0.8 0.5 #0.1 0.01 0.001 0.0001 -do - - dir="compare_"$p"/" - cd $dir - pwd - ls -l output/*.json | awk '{print $9}' > json_files - sed -e s/\.json//g -i json_files - for i in `cat json_files` - do - mv output/$i.json output/$i.csv - done -done diff --git a/scripts/analysis.py b/scripts/analysis.py index 4a4e7af..e904d4c 100644 --- a/scripts/analysis.py +++ b/scripts/analysis.py @@ -113,16 +113,15 @@ def plot_view_times(nwsize2vfins, simtype, oprefix): logbands[simtype]["high"] = [] if simtype == "branch": - low, high = 4, 8 + low, high = 0.75, 1.5 else: - low, high = 1, 2 + low, high = 0.75, 1.5 data = [[], []] - print("READ FROM FILE", nwsize2vfins) for n in sorted(list(map(int, nwsize2vfins.keys()))): vfin = nwsize2vfins[n] - #print(f"{simtype} {nwsize2vfins[n]}", end=' == ') + print(f"{simtype} {nwsize2vfins[n]}", end=' == ') for run in vfin: - if "default" in run[3] and simtype in run[0]: + if "nolat" in run[3] and simtype in run[0]: data[0].append(n) data[1].append(int(run[2][0])) print(f"IF: {simtype}={run[0]} : {n} {run[3]}") @@ -163,6 +162,19 @@ def plot_tree_vs_branch(tree, branch, oprefix): fig.set_figwidth(12) fig.set_figheight(10) + fig.suptitle(f'View Finalisation Times - Tree vs Branch') + axes.set_xlabel("Tree") + axes.set_ylabel("Branch") + + + #print("\nT, B:", tree[1], branch[1]) + branch[1].insert(0, 6) + print("\nT, B:", tree[1], branch[1]) + axes.scatter(tree[1], branch[1]) + + axes.plot([0, 1], [0, 1], linestyle='dashed', transform=axes.transAxes) + + ''' fig.suptitle(f'View Finalisation Times - Tree vs Branch') axes.set_xlabel("Number of Nodes") axes.set_ylabel("Number of Epochs") @@ -170,7 +182,7 @@ def plot_tree_vs_branch(tree, branch, oprefix): axes.scatter(tree[0], tree[1], label="Tree") axes.scatter(branch[0], branch[1], label="Branch") - axes.legend( loc="upper right") + ''' plt.show() plt.savefig(f'{oprefix}-scatter.pdf', format="pdf", bbox_inches="tight") @@ -204,18 +216,16 @@ def views(ctx: typer.Context, exists=True, dir_okay=True, readable=True, help="Set the simulation config file"), oprefix: str = typer.Option("output", - help="Set the output prefix for the plots"), - simtype: str = typer.Option("tree", - help="Set the type of the simulation") + help="Set the output prefix for the plots") ): print("here 1 ") log.basicConfig(level=log.INFO) - nwsize2vfins = compute_view_times(path, oprefix) - print("here writing ") - write_dict(nwsize2vfins, f'{oprefix}-{simtype}-viewtimes.dict') + #nwsize2vfins = compute_view_times(path, oprefix) + #write_dict(nwsize2vfins, f'{oprefix}-viewtimes.dict') - nwsize2vfins = read_dict(f'{oprefix}-{simtype}-viewtimes.dict') + print("reading ") + nwsize2vfins = read_dict(f'{oprefix}-viewtimes.dict') tree = plot_view_times(nwsize2vfins, "tree", oprefix) branch = plot_view_times(nwsize2vfins, "branch", oprefix)