Files
seaweedfs/seaweed-block/docs/assets/readme-chart.py
T
pingqiuandClaude Opus 5.5 636009705b docs(readme): provenance, flush-inclusive figures, ownership, no comparison yet
The workload rows are a pre-release walstore build timing the operation
itself; the page and the measurements give the figures with the final
syncfs too (11-23% for the README rows; 4-36x against the FUSE
prototype, now described as such). The recovery point is 'normally about
a day', not a bound. A write does not wait on SeaweedFS except a restored
volume's first fetch of a chunk. Ownership names lease admission and the
one-blockmaster rule beside the HEAD fencing. The fault-injection record
states its scope and the night's other failures. The comparison table
leaves the page until others' names and sources can be public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 12:44:03 -08:00

123 lines
5.3 KiB
Python

#!/usr/bin/env python3
"""Draw the README's measured-results chart from docs/assets/measured-results.csv.
Each workload's time on Seaweed Block is shown relative to the same workload on
a local disk (local disk = 1.0), so rows with different units share one axis.
Writes a light and a dark SVG next to the CSV. With --check, it writes nothing
and exits 1 if either SVG differs from what the CSV gives.
usage: python3 docs/assets/readme-chart.py [--check]
"""
import csv
import sys
from pathlib import Path
from xml.sax.saxutils import escape
ROOT = Path(__file__).resolve().parent.parent.parent
CSV = ROOT / "docs" / "assets" / "measured-results.csv"
OUT = {"light": ROOT / "docs" / "assets" / "measured-results-light.svg",
"dark": ROOT / "docs" / "assets" / "measured-results-dark.svg"}
THEMES = {
"light": {"surface": "#fcfcfb", "ink": "#0b0b0b", "ink2": "#52514e", "grid": "#e4e3df",
"ref": "#52514e", "bar": "#2a78d6"},
"dark": {"surface": "#1a1a19", "ink": "#f0efec", "ink2": "#c3c2b7", "grid": "#383835",
"ref": "#c3c2b7", "bar": "#3987e5"},
}
W, LABEL_W, RIGHT_W = 760, 250, 150
ROW_H, BAR_H, TOP, BOTTOM = 34, 14, 56, 44
XMAX = 2.0
TICKS = [0.0, 0.5, 1.0, 1.5, 2.0]
def rows():
with CSV.open(encoding="utf-8", newline="") as f:
out = []
for r in csv.DictReader(f):
sb, local = float(r["seaweed_block"]), float(r["local_disk"])
out.append((r["workload"], sb, local, r["unit"], r["frontend"]))
return out
def fmt(v, unit):
return f"{v:.2f} {unit}"
def bar_path(x0, y, w, h, r=4):
"""A bar anchored at x0 with a rounded data end (right side only)."""
r = min(r, w, h / 2)
x1 = x0 + w
return (f"M{x0:.1f},{y:.1f} H{x1 - r:.1f} Q{x1:.1f},{y:.1f} {x1:.1f},{y + r:.1f} "
f"V{y + h - r:.1f} Q{x1:.1f},{y + h:.1f} {x1 - r:.1f},{y + h:.1f} H{x0:.1f} Z")
def svg(theme):
t = THEMES[theme]
data = rows()
for w, sb, lo, _, _ in data:
if sb / lo > XMAX:
raise SystemExit(f"{w}: {sb / lo:.2f} is beyond the axis ({XMAX}); raise XMAX")
plot_w = W - LABEL_W - RIGHT_W
h = TOP + ROW_H * len(data) + BOTTOM
def x(v):
return LABEL_W + plot_w * v / XMAX
parts = [
f'<svg xmlns="http://www.w3.org/2000/svg" width="{W}" height="{h}" viewBox="0 0 {W} {h}" '
f'role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">',
'<title id="t">Workload time on Seaweed Block relative to a local disk</title>',
'<desc id="d">' + escape("; ".join(
f"{w}: {sb / lo:.2f} times local ({fmt(sb, u)} against {fmt(lo, u)})" for w, sb, lo, u, _ in data)) + '</desc>',
f'<rect width="{W}" height="{h}" fill="{t["surface"]}"/>',
f'<text x="16" y="24" font-size="15" font-weight="600" fill="{t["ink"]}">'
'Time on Seaweed Block relative to a local disk (local disk = 1.0)</text>',
f'<text x="16" y="42" font-size="12" fill="{t["ink2"]}">'
'Lab runs over NVMe/TCP loopback, median of 3, not SLOs. Lower is faster.</text>',
]
for v in TICKS:
parts.append(f'<line x1="{x(v):.1f}" y1="{TOP - 6}" x2="{x(v):.1f}" y2="{TOP + ROW_H * len(data)}" '
f'stroke="{t["grid"]}" stroke-width="1"/>')
parts.append(f'<text x="{x(v):.1f}" y="{TOP + ROW_H * len(data) + 18}" font-size="11" '
f'text-anchor="middle" fill="{t["ink2"]}">{v:.1f}</text>')
parts.append(f'<line x1="{x(1.0):.1f}" y1="{TOP - 6}" x2="{x(1.0):.1f}" y2="{TOP + ROW_H * len(data)}" '
f'stroke="{t["ref"]}" stroke-width="1.5" stroke-dasharray="4 3"/>')
parts.append(f'<text x="{x(1.0):.1f}" y="{TOP + ROW_H * len(data) + 34}" font-size="11" '
f'text-anchor="middle" fill="{t["ink2"]}">local disk</text>')
for i, (w, sb, lo, u, fe) in enumerate(data):
yc = TOP + ROW_H * i + ROW_H / 2
ratio = sb / lo
parts.append(f'<text x="{LABEL_W - 10}" y="{yc - 2:.1f}" font-size="12" text-anchor="end" '
f'fill="{t["ink"]}">{escape(w)}</text>')
parts.append(f'<text x="{LABEL_W - 10}" y="{yc + 11:.1f}" font-size="10" text-anchor="end" '
f'fill="{t["ink2"]}">{escape(fe)}</text>')
parts.append(f'<path d="{bar_path(x(0), yc - BAR_H / 2, x(min(ratio, XMAX)) - x(0), BAR_H)}" '
f'fill="{t["bar"]}"><title>{escape(w)}: {ratio:.2f} x local '
f'({fmt(sb, u)} against {fmt(lo, u)})</title></path>')
parts.append(f'<text x="{x(XMAX) + 10:.1f}" y="{yc + 4:.1f}" font-size="12" fill="{t["ink"]}">'
f'{ratio:.2f}x <tspan fill="{t["ink2"]}" font-size="11">'
f'({fmt(sb, u)} / {fmt(lo, u)})</tspan></text>')
parts.append("</svg>")
return "\n".join(parts) + "\n"
def main():
check = sys.argv[1:] == ["--check"]
stale = []
for theme, path in OUT.items():
text = svg(theme)
if check:
if not path.exists() or path.read_text(encoding="utf-8").replace("\r\n", "\n") != text:
stale.append(str(path.relative_to(ROOT)))
else:
path.write_text(text, encoding="utf-8", newline="\n")
if stale:
print("stale, rerun docs/assets/readme-chart.py: " + ", ".join(stale))
return 1
return 0
if __name__ == "__main__":
sys.exit(main())