mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-01-10 00:53:11 +00:00
nolat runs
This commit is contained in:
parent
e6d29df9d4
commit
2a9236fb81
@ -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 <path_to_csv_file>")
|
||||
sys.exit(1)
|
||||
|
||||
csv_path = sys.argv[1]
|
||||
build_cases(csv_path)
|
||||
|
||||
48
run.sh
48
run.sh
@ -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
|
||||
@ -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)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user