Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for REST bugs and certain metrics in bench #32

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions alluxio-py-bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def init_main_parser():
return parser


def main(main_args, remaining_args, test_suite=AbstractBench):
def main(main_args, test_suite=AbstractBench):
if not test_suite:
print("No test suite specified, bail.")
return
Expand All @@ -67,23 +67,27 @@ def main(main_args, remaining_args, test_suite=AbstractBench):
if processid <= 0:
i_am_child = True
print(f"Child Process:{i}")
before_time = time.time()
while time.time() - start_time < main_args.runtime:
before_time = time.time()
result_metrics = test_suite.execute()
duration = time.time() - before_time
if result_metrics.get(Metrics.TOTAL_OPS):
print(
f"Benchmark against {remaining_args.op}: total ops: {result_metrics.get(Metrics.TOTAL_OPS)}, ops/second: {result_metrics[Metrics.TOTAL_OPS] / duration}"
)
if result_metrics.get(Metrics.TOTAL_BYTES):
print(
f"Benchmark against {remaining_args.op}: total bytes: {result_metrics.get(Metrics.TOTAL_BYTES)}, bytes/second: {result_metrics[Metrics.TOTAL_BYTES] / duration}"
)
duration = time.time() - before_time
if result_metrics.get(Metrics.TOTAL_OPS):
print(
f"Benchmark against {test_suite.args.op}: "
f"total ops: {result_metrics.get(Metrics.TOTAL_OPS)}, "
f"ops/second: {result_metrics.get(Metrics.TOTAL_OPS) / duration}"
)
if result_metrics.get(Metrics.TOTAL_BYTES):
print(
f"Benchmark against {test_suite.args.op}: "
f"total bytes: {result_metrics.get(Metrics.TOTAL_BYTES)}, "
f"bytes/second: {result_metrics.get(Metrics.TOTAL_BYTES) / duration}"
)

if not result_metrics:
print(
f"Benchmark against {remaining_args.op}: iteration: {remaining_args.iteration} total time: {duration} seconds"
)
if not result_metrics:
print(
f"Benchmark against {test_suite.args.op}: iteration: {test_suite.args.iteration} total time: {duration} seconds"
)
print(f"Child Process:{i} exit")
break
else:
Expand Down Expand Up @@ -112,4 +116,4 @@ def main(main_args, remaining_args, test_suite=AbstractBench):
elif main_args.testsuite == TestSuite.RAY.name:
suite_parser = RayBench.RayArgumentParser(main_parser)
testsuite = RayBench.RayBench(suite_parser.parse_args())
main(main_args, remaining_args, testsuite)
main(main_args, testsuite)
3 changes: 2 additions & 1 deletion alluxiofs/client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ def read_range(self, file_path, offset, length):
)
except Exception as e:
raise Exception(
f"Error when reading file {file_path}: error {e}"
f"Error when reading file {file_path}: error {e}: "
f"worker_host{worker_host}, worker_http_port:{worker_http_port}"
) from e

def write_page(self, file_path, page_index, page_bytes):
Expand Down
17 changes: 0 additions & 17 deletions tests/benchmark/AlluxioFSSpecBench.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import random
import time
from enum import Enum

from alluxiofs import AlluxioFileSystem
Expand Down Expand Up @@ -60,7 +59,6 @@ def init(self):
self.metrics = Metrics()

def execute(self) -> Metrics:
start_time = time.time()
for i in range(self.args.iteration):
if self.args.op == Op.ls.value:
result_metrics = self.bench_ls()
Expand All @@ -78,21 +76,6 @@ def execute(self) -> Metrics:
)
for _, (k, v) in enumerate(result_metrics.items()):
self.metrics.update(k, v)
duration = time.time() - start_time

if self.metrics.get(Metrics.TOTAL_OPS):
print(
f"Benchmark against {self.args.op}: total ops: {self.metrics.get(Metrics.TOTAL_OPS)}, ops/second: {result_metrics[Metrics.TOTAL_OPS] / duration}"
)
if self.metrics.get(Metrics.TOTAL_BYTES):
print(
f"Benchmark against {self.args.op}: total bytes: {self.metrics.get(Metrics.TOTAL_BYTES)}, bytes/second: {result_metrics[Metrics.TOTAL_BYTES] / duration}"
)

if not result_metrics:
print(
f"Benchmark against {self.args.op}: iteration: {self.args.iteration} total time: {duration} seconds"
)
return self.metrics

def traverse(self, path, directories, files):
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmark/AlluxioRESTBench.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def testGetPage(self):
try:
response = self.session.get(
FULL_PAGE_URL_FORMAT.format(
worker_host=self.worker,
worker_host=self.worker_host,
http_port=ALLUXIO_WORKER_HTTP_SERVER_PORT_DEFAULT_VALUE,
path_id=self.args.fileid,
page_index=page_idx,
Expand All @@ -149,7 +149,7 @@ def testGetPage(self):
self.metrics.update(Metrics.TOTAL_BYTES, content_len)
except Exception as e:
raise Exception(
f"Error ListFiles, path:{self.path}: error {e}"
f"Error GetPage, path:{self.path}: error {e}"
) from e

def testListFiles(self):
Expand Down
Loading