Skip to content

Commit

Permalink
Problem: test tx generation can't be run in parallel (#1596)
Browse files Browse the repository at this point in the history
Solution:
- support generating a single node and use shell to parallelize it

for example:
```
$ seq 0 9 | xargs -P10 -I{} nix run .#stateless-testcase -- gen-txs /tmp/data/out --node {}
```
  • Loading branch information
yihuang authored Sep 23, 2024
1 parent 26f1a62 commit 8b0d1ea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions testground/benchmark/benchmark/stateless.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tempfile
import time
from pathlib import Path
from typing import List
from typing import List, Optional

import click
import tomlkit
Expand Down Expand Up @@ -203,6 +203,7 @@ def run(outdir: str, datadir: str, cronosd, global_seq):
@click.option("--nodes", default=10)
@click.option("--num-accounts", default=10)
@click.option("--num-txs", default=1000)
@click.option("--node", type=int)
def gen_txs(**kwargs):
return _gen_txs(**kwargs)

Expand All @@ -218,14 +219,22 @@ def _gen_txs(
nodes: int = 10,
num_accounts: int = 10,
num_txs: int = 1000,
node: Optional[int] = None,
):
outdir = Path(outdir)
for global_seq in range(nodes):

def job(global_seq):
print("generating", num_accounts * num_txs, "txs for node", global_seq)
txs = transaction.gen(global_seq, num_accounts, num_txs)
transaction.save(txs, outdir, global_seq)
print("saved", len(txs), "txs for node", global_seq)

if node is not None:
job(node)
else:
for global_seq in range(nodes):
job(global_seq)


def do_run(
datadir: Path, home: Path, cronosd: str, group: str, global_seq: int, cfg: dict
Expand Down

0 comments on commit 8b0d1ea

Please sign in to comment.