From 80df109138253285b03b02ac4b8a82cf24d324fe Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 4 Nov 2024 14:25:06 +0800 Subject: [PATCH 1/3] Problem: output artifact gets expired easily record in log --- testground/benchmark/benchmark/stats.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testground/benchmark/benchmark/stats.py b/testground/benchmark/benchmark/stats.py index f59d4c91a9..694cc661b3 100644 --- a/testground/benchmark/benchmark/stats.py +++ b/testground/benchmark/benchmark/stats.py @@ -57,6 +57,7 @@ def dump_block_stats( blocks.append((txs, timestamp)) tps = calculate_tps(blocks[-TPS_WINDOW:]) tps_list.append(tps) + print("block", i, txs, timestamp, tps) print("block", i, txs, timestamp, tps, file=fp) tps_list.sort(reverse=True) print("top_tps", tps_list[:5], file=fp) From 624251ffa07909fc0c34a76aa82feb11e08926aa Mon Sep 17 00:00:00 2001 From: HuangYi Date: Mon, 4 Nov 2024 15:57:01 +0800 Subject: [PATCH 2/3] cleanup --- testground/benchmark/benchmark/stateless.py | 4 ++-- testground/benchmark/benchmark/stats.py | 1 - testground/benchmark/benchmark/utils.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/testground/benchmark/benchmark/stateless.py b/testground/benchmark/benchmark/stateless.py index ac07d83cfc..69d3835acd 100644 --- a/testground/benchmark/benchmark/stateless.py +++ b/testground/benchmark/benchmark/stateless.py @@ -28,7 +28,7 @@ from .stats import dump_block_stats from .topology import connect_all from .types import PeerPacket -from .utils import block_height, block_txs, wait_for_block, wait_for_port +from .utils import Tee, block_height, block_txs, wait_for_block, wait_for_port # use cronosd on host machine LOCAL_CRONOSD_PATH = "cronosd" @@ -303,7 +303,7 @@ def do_run( detect_idle_halted(cfg["num_idle"], 5) with (home / "block_stats.log").open("w") as logfile: - dump_block_stats(logfile) + dump_block_stats(Tee(logfile, sys.stdout)) proc.kill() proc.wait(20) diff --git a/testground/benchmark/benchmark/stats.py b/testground/benchmark/benchmark/stats.py index 694cc661b3..f59d4c91a9 100644 --- a/testground/benchmark/benchmark/stats.py +++ b/testground/benchmark/benchmark/stats.py @@ -57,7 +57,6 @@ def dump_block_stats( blocks.append((txs, timestamp)) tps = calculate_tps(blocks[-TPS_WINDOW:]) tps_list.append(tps) - print("block", i, txs, timestamp, tps) print("block", i, txs, timestamp, tps, file=fp) tps_list.sort(reverse=True) print("top_tps", tps_list[:5], file=fp) diff --git a/testground/benchmark/benchmark/utils.py b/testground/benchmark/benchmark/utils.py index 786b7f17fa..00fd523384 100644 --- a/testground/benchmark/benchmark/utils.py +++ b/testground/benchmark/benchmark/utils.py @@ -207,3 +207,13 @@ def split_batch(a: int, size: int): if m: parts.append((k * size, a)) return parts + +class Tee: + def __init__(self, f1, f2): + self.f1 = f1 + self.f2 = f2 + def write(self, s) -> int: + s1 = self.f1.write(s) + s2 = self.f2.write(s) + assert s1 = s2 + return s1 From f2a3362db0d54c2e8cec3d6dd88faa2c822e2959 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Mon, 4 Nov 2024 15:58:26 +0800 Subject: [PATCH 3/3] fix --- testground/benchmark/benchmark/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testground/benchmark/benchmark/utils.py b/testground/benchmark/benchmark/utils.py index 00fd523384..a3ad823681 100644 --- a/testground/benchmark/benchmark/utils.py +++ b/testground/benchmark/benchmark/utils.py @@ -208,12 +208,14 @@ def split_batch(a: int, size: int): parts.append((k * size, a)) return parts + class Tee: def __init__(self, f1, f2): self.f1 = f1 self.f2 = f2 + def write(self, s) -> int: s1 = self.f1.write(s) s2 = self.f2.write(s) - assert s1 = s2 + assert s1 == s2 return s1