1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import argparse
import json
from replay_report import read_case
from pathlib import Path
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser()
parser.add_argument('summary', type=Path)
parser.add_argument('output', type=Path)
args = parser.parse_args()
generated = args.summary.is_dir()
if generated:
rows = {directory.name: read_case(directory) for directory in sorted(args.summary.iterdir())
if directory.is_dir() and (directory / 'counters.json').exists() and 'calibration' not in directory.name}
else:
rows = {row['case']: row for row in json.loads(args.summary.read_text())}
fig, axes = plt.subplots(1, 2, figsize=(13, 5.6))
cases = ['full-1000', 'profile-1000', 'workers16-1000', 'workers16-1000-repeat', 'workers16-5000']
labels = ['4 workers\n1k/s, no probes', '4 workers\n1k/s, probes', '16 workers\n1k/s, first', '16 workers\n1k/s, repeat', '16 workers\n5k/s']
if generated:
cases = sorted(key.removeprefix('zkv-') for key in rows if key.startswith('zkv-'))
labels = [f"{case.removeprefix('zds-')}\n{rows[f'zkv-{case}']['frames']:,} frames, {rows[f'zkv-{case}']['offered_rate']:,}/s" for case in cases]
for case in cases:
assert rows[f'zkv-{case}']['frames'] == rows[f'rocks-{case}']['frames']
for i, (engine, color, label) in enumerate([('zkv', '#176d9c', 'ZKV'), ('rocks', '#b55b25', 'RocksDB synchronous')]):
values = [rows[f'{engine}-{case}']['completion_seconds'] for case in cases]
bars = axes[0].bar([x + (i - .5) * .34 for x in range(len(cases))], values, .32, color=color, label=label)
axes[0].bar_label(bars, labels=[f'{value:.1f}' for value in values], padding=3, fontsize=9)
axes[0].set_xticks(range(len(cases)), labels, fontsize=8)
axes[0].set_ylabel('Seconds for stated workload' if generated else 'Seconds for 3,300 frames')
axes[0].set_title('Time through final event-file write', loc='left', fontsize=12)
axes[0].legend(frameon=False, fontsize=9)
positions = ['zkv-profile-1000', 'rocks-profile-1000', 'zkv-workers16-1000', 'rocks-workers16-1000']
if generated:
positions = [f'{engine}-{case}' for case in cases for engine in ['zkv', 'rocks']]
bottom = [0.] * len(positions)
for key, color, label in [
('other', '#bcc6d0', 'Other processing'), ('validate', '#6b803e', 'Signature + proof'),
('index', '#8c5cb3', 'Index call'), ('post_index', '#247d80', 'Persistence + state update'),
]:
values = []
for case in positions:
profile = rows[case]['profiles']
ns = profile['frame']['total_ns'] - sum(profile[k]['total_ns'] for k in ['validate', 'index', 'post_index']) if key == 'other' else profile[key]['total_ns']
values.append(ns / profile['frame']['count'] / 1e6)
axes[1].bar(range(len(positions)), values, bottom=bottom, color=color, label=label)
bottom = [a + b for a, b in zip(bottom, values)]
ticks = ['4 workers\nZKV', '4 workers\nRocksDB', '16 workers\nZKV', '16 workers\nRocksDB']
if generated:
ticks = [f"{'ZKV' if key.startswith('zkv-') else 'RocksDB'}\n{key.split('-', 2)[-1]}" for key in positions]
axes[1].set_xticks(range(len(positions)), ticks, fontsize=9)
axes[1].set_ylabel('Mean milliseconds per frame')
axes[1].set_title('Worker time, including I/O and queue waits', loc='left', fontsize=12)
axes[1].legend(frameon=False, fontsize=8, ncol=2, loc='upper left')
for ax in axes:
ax.spines[['top', 'right']].set_visible(False)
ax.set_axisbelow(True)
ax.grid(axis='y', alpha=.15)
ax.set_ylim(0, ax.get_ylim()[1] * 1.25)
fig.suptitle('Generated offline relay workloads' if generated else 'Offline relay burst measurements', x=.07, ha='left', fontsize=17)
fig.text(.07, .89, 'Identical signed frames per pair; relay capped at 2 CPUs / 512 MiB; PostgreSQL capped at 1 CPU / 256 MiB.', fontsize=10)
footnote = 'Fresh revisions from ZDS; warmed membership prefix included. 16 workers. Upstream transport excluded; short screening runs.' if generated else 'Fresh account rows and index. Captured identity trust; upstream transport/discovery excluded. Short bursts, not sustained-capacity proof.'
fig.text(.07, .045, footnote, fontsize=9)
fig.subplots_adjust(left=.07, right=.98, top=.77, bottom=.23, wspace=.3)
fig.savefig(args.output, facecolor='white')
fig.savefig(args.output.with_suffix('.png'), dpi=150, facecolor='white')