Skip to content

Commit

Permalink
feat: change default port number and bump rocksdb version
Browse files Browse the repository at this point in the history
  • Loading branch information
asonnino committed Oct 12, 2024
1 parent 7c385a0 commit f5145b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
40 changes: 23 additions & 17 deletions benchmark/benchmark/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,55 @@
from time import sleep

from benchmark.commands import CommandMaker
from benchmark.config import Key, LocalCommittee, NodeParameters, BenchParameters, ConfigError
from benchmark.config import (
Key,
LocalCommittee,
NodeParameters,
BenchParameters,
ConfigError,
)
from benchmark.logs import LogParser, ParseError
from benchmark.utils import Print, BenchError, PathMaker


class LocalBench:
BASE_PORT = 3000
BASE_PORT = 4000

def __init__(self, bench_parameters_dict, node_parameters_dict):
try:
self.bench_parameters = BenchParameters(bench_parameters_dict)
self.node_parameters = NodeParameters(node_parameters_dict)
except ConfigError as e:
raise BenchError('Invalid nodes or bench parameters', e)
raise BenchError("Invalid nodes or bench parameters", e)

def __getattr__(self, attr):
return getattr(self.bench_parameters, attr)

def _background_run(self, command, log_file):
name = splitext(basename(log_file))[0]
cmd = f'{command} 2> {log_file}'
subprocess.run(['tmux', 'new', '-d', '-s', name, cmd], check=True)
cmd = f"{command} 2> {log_file}"
subprocess.run(["tmux", "new", "-d", "-s", name, cmd], check=True)

def _kill_nodes(self):
try:
cmd = CommandMaker.kill().split()
subprocess.run(cmd, stderr=subprocess.DEVNULL)
except subprocess.SubprocessError as e:
raise BenchError('Failed to kill testbed', e)
raise BenchError("Failed to kill testbed", e)

def run(self, debug=False):
assert isinstance(debug, bool)
Print.heading('Starting local benchmark')
Print.heading("Starting local benchmark")

# Kill any previous testbed.
self._kill_nodes()

try:
Print.info('Setting up testbed...')
Print.info("Setting up testbed...")
nodes, rate = self.nodes[0], self.rate[0]

# Cleanup all files.
cmd = f'{CommandMaker.clean_logs()} ; {CommandMaker.cleanup()}'
cmd = f"{CommandMaker.clean_logs()} ; {CommandMaker.cleanup()}"
subprocess.run([cmd], shell=True, stderr=subprocess.DEVNULL)
sleep(0.5) # Removing the store may take time.

Expand Down Expand Up @@ -77,12 +83,12 @@ def run(self, debug=False):
workers_addresses = committee.workers_addresses(self.faults)
rate_share = ceil(rate / committee.workers())
for i, addresses in enumerate(workers_addresses):
for (id, address) in addresses:
for id, address in addresses:
cmd = CommandMaker.run_client(
address,
self.tx_size,
rate_share,
[x for y in workers_addresses for _, x in y]
[x for y in workers_addresses for _, x in y],
)
log_file = PathMaker.client_log_file(i, id)
self._background_run(cmd, log_file)
Expand All @@ -94,34 +100,34 @@ def run(self, debug=False):
PathMaker.committee_file(),
PathMaker.db_path(i),
PathMaker.parameters_file(),
debug=debug
debug=debug,
)
log_file = PathMaker.primary_log_file(i)
self._background_run(cmd, log_file)

# Run the workers (except the faulty ones).
for i, addresses in enumerate(workers_addresses):
for (id, address) in addresses:
for id, address in addresses:
cmd = CommandMaker.run_worker(
PathMaker.key_file(i),
PathMaker.committee_file(),
PathMaker.db_path(i, id),
PathMaker.parameters_file(),
id, # The worker's id.
debug=debug
debug=debug,
)
log_file = PathMaker.worker_log_file(i, id)
self._background_run(cmd, log_file)

# Wait for all transactions to be processed.
Print.info(f'Running benchmark ({self.duration} sec)...')
Print.info(f"Running benchmark ({self.duration} sec)...")
sleep(self.duration)
self._kill_nodes()

# Parse logs and return the parser.
Print.info('Parsing logs...')
Print.info("Parsing logs...")
return LogParser.process(PathMaker.logs_path(), faults=self.faults)

except (subprocess.SubprocessError, ParseError) as e:
self._kill_nodes()
raise BenchError('Failed to run benchmark', e)
raise BenchError("Failed to run benchmark", e)
4 changes: 2 additions & 2 deletions store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2018"
publish = false

[dependencies]
rocksdb = "0.16.0"
tokio = { version = "1.5.0", features = ["sync", "macros", "rt"] }
rocksdb = "0.22.0"
tokio = { version = "1.5.0", features = ["sync", "macros", "rt"] }

0 comments on commit f5145b7

Please sign in to comment.