diff --git a/SPECS.md b/SPECS.md index 4340042..af66d5b 100644 --- a/SPECS.md +++ b/SPECS.md @@ -177,6 +177,9 @@ These come from the owner and are not negotiable. - **Edit files with the Edit tool** (or Write for new files). Do not use Python, `sed -i` or similar scripts to modify files. - **Scratch files go in `.tmp/` in the project**, not `/tmp`. +- **Run `scripts/sim-sweep.sh` only when the owner says so**, and render + graphs and dashboards locally (`scripts/sim-dashboard.mjs`); never publish + them to claude.ai. - **Ask design decisions with the question tool**, but not routinely: pick the conventional default for small things and say so. - **Commit and push finished work to `main`** (allow rules for `git commit` and diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 2bc1c90..971e655 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -623,8 +623,11 @@ packet loss looks like above TCP), `-hostile` (an attacker with no validators), **How large a network can it carry?** `scripts/sim-sweep.sh` runs growing networks (8 regions, 3 seeds, 30 listings, 20 messages, 3 reports, 10% churn) -and records each as JSON in `.tmp/sim/`; `scripts/sim-report.mjs` turns them -into the tables behind the graphs. Result on a 16 GB, 8-core machine: +and records each as JSON in `.tmp/sim/` (run it only when you mean to: it takes +many minutes and several GB of memory). `node scripts/sim-report.mjs` turns the +runs into tables and `node scripts/sim-dashboard.mjs` builds +`.tmp/sim/dashboard.html`, a self-contained page with the graphs; nothing is +uploaded anywhere. Result on a 16 GB, 8-core machine: | Nodes | As shipped (`--public` accepts 1000) | libp2p's own default limit (before the fix) | |---|---|---| diff --git a/scripts/sim-dashboard.mjs b/scripts/sim-dashboard.mjs new file mode 100644 index 0000000..9a75c76 --- /dev/null +++ b/scripts/sim-dashboard.mjs @@ -0,0 +1,26 @@ +// Builds one self-contained HTML page with the graphs of the simulator runs. +// Nothing is uploaded anywhere; open the file in a browser. +// +// node scripts/sim-report.mjs # turn the runs in .tmp/sim into tables +// node scripts/sim-dashboard.mjs # -> .tmp/sim/dashboard.html +import { readFileSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const dir = resolve(process.argv[2] ?? join(here, "..", ".tmp", "sim")); +const read = (name) => JSON.parse(readFileSync(join(dir, "data", `${name}.json`), "utf8")); + +const data = { + scaling: read("scaling"), + timeline: read("timeline"), + phases: read("phases"), + arrival: read("arrival"), + generated: new Date().toISOString().slice(0, 16).replace("T", " "), +}; +// "<" cannot appear in the JSON, so the data can never close its own script tag +const json = JSON.stringify(data).replace(/ json); +const out = join(dir, "dashboard.html"); +writeFileSync(out, page); +console.log(`wrote ${out} (${Math.round(page.length / 1024)} KB, ${data.scaling.length} runs)`); diff --git a/scripts/sim-dashboard.template.html b/scripts/sim-dashboard.template.html new file mode 100644 index 0000000..b19f724 --- /dev/null +++ b/scripts/sim-dashboard.template.html @@ -0,0 +1,372 @@ + + + + + +Allmende network tests + + + +
+
+

Allmende network tests

+

+
+ +
+
+

How many nodes can the network carry?

+

Each point is one run of real nodes in one process. The two lines differ in one thing: how many inbound connections the three seed nodes accept. A hollow point means the mesh never formed completely within the wait.

+
+
+

Listings that arrived, in %

+

Time until every node knew regional peers, in seconds

+

A listing reaches 95% of its nodes within, in ms

+

Nodes that never found a single peer

+
+
+ +
+
+

What it costs

+

Totals for all nodes together, since they share one process. Real nodes each pay only their own share.

+
+
+

Peak memory (heap), in MB

+

CPU time used by the run, in seconds

+

Peak goroutines

+

Traffic sent per node, in KB

+
+
+ +
+
+
+

One run over time

+

Shaded bands alternate between the phases of the run: start, mesh formation, listings, messages, reports, then nodes leaving and coming back.

+
+ +
+
+
+ +
+
+

How fast a listing arrives

+

The share of all expected deliveries that had happened after a given time. A line that stops below 100% shows nodes the listing never reached.

+
+
+
+ +
+

All runs

+
+ + +
+
+ +
+ How these tests ran +

Every node is the real thing: a libp2p host, gossipsub, the DHT, a store and its own identity. They run in one Go process on one machine and talk over loopback, so there is no real latency, packet loss or NAT. Three seed nodes are reachable by everyone and follow no region; every other node follows one region, a fifth of them two. Each run publishes 30 listings, sends 20 messages and 3 abuse reports, then takes a tenth of the nodes offline while more listings appear and brings them back. "Listings that arrived" counts every delivery to a node that follows the listing's region.

+

The seeds' connection limit is how many inbound connections a --public node accepts: 1000 as shipped, and libp2p's own default in the comparison runs (it scales with memory and was about 190 on a 16 GB machine, which is what stranded nodes before it was set). Run scripts/sim-sweep.sh, then node scripts/sim-dashboard.mjs to rebuild this page.

+
+ +
+ + + + +