Versions 39 to 318
new file, 448 lines
2+// A scale harness for abso's open server (server/). It talks HTTP directly, as the client does, so one machine can
3+// play thousands of agents across many projects. Each project is its own Durable Object and Artifacts repo, so total
4+// pushes a second should grow with the number of projects while each project's own latency stays flat.
6+// node server/scale/scale.mjs --server <url> [--projects 10] [--agents 5] [--rounds 3] [--overlap 0.2]
9+// The token comes from ABSO_TOKEN, or from the file --token-file names. It is never printed. README.md says more.
10+
15+
26+
69+
75+
76+const round = (n, places = 1) => (n === null || n === undefined ? null : Math.round(n * 10 ** places) / 10 ** places);
77+
97+
143+
188+
190+const hotText = () => Array.from({ length: HOT_LINES }, (_, i) => `hot line ${i + 1}`).join("\n") + "\n";
191+
192+/** Makes a project: one starting file per agent is left to the agents; init holds the hot file, a readme and a blob. */
201+ { files: { "README.md": `# ${project}\n\nA scale run.\n`, "hot.txt": hotText() }, blobs: { "logo.bin": sha } },
206+
207+/** One agent: join, say what it starts on, then rounds of edit, record and publish. A held push pulls and retries once. */
220+ await client.call("POST", `${base}/starting`, { text: `Scale run: ${agent} edits its own file` }, "starting");
242+ let pub = await client.call("POST", `${base}/publish`, { message: `${agent} round ${r}` }, "publish");
245+ // Settle: pull (both sides' lines come back), then push with both sides kept, as abso push --as-is does.
264+
265+/** For a sample of projects: how long after its last push until /out says Artifacts holds shared's newest version. */
276+ return { project, version: b.version, seconds: round((Date.now() - last) / 1000), error: null };
285+ error: b.error ? `not pushed: ${JSON.stringify(b.error).slice(0, 160)}` : "not pushed in time",
303+
309+ const projects = Array.from({ length: o.projects }, (_, i) => `${o.prefix}-${name}-p${i + 1}`.toLowerCase());
318+ Array.from({ length: o.agents }, (_, a) => runAgent(client, stats, p, `agent-${a + 1}`, o, deadline)),
323+ const perProject = [...stats.perProject.values()].map((n) => n / seconds).sort((a, b) => a - b);
355+ failedProjects: projects.filter((_, i) => !made[i].ok).map((p, i) => ({ project: p, why: made[i]?.why })),
358+
361+ const lag = r.artifacts.p50Seconds === null ? "n/a" : `${r.artifacts.p50Seconds} s (max ${r.artifacts.maxSeconds} s)`;
362+ return `| ${r.projectsMade}×${r.agentsPerProject} | ${r.agents} | ${r.pushes} | ${r.pushesPerSecond} | ${pub.p50 ?? "n/a"} | ${pub.p95 ?? "n/a"} | ${r.held} (${r.heldAfterRetry} still held) | ${r.errors} (${(r.errorRate * 100).toFixed(2)}%) | ${lag} (${r.artifacts.pushedOut}/${r.artifacts.sampled}) |`;
364+
366+ "| Stage (projects×agents) | Agents | Pushes | Pushes/s | Push p50 ms | Push p95 ms | Held | Errors | Artifacts lag p50 (pushed/sampled) |",
369+
371+ const lines = ["| Operation | Count | p50 ms | p95 ms | p99 ms | max ms |", "|---|---|---|---|---|---|"];
376+
385+
402+ console.error(`stage ${name}: ${projects} projects × ${agents} agents × ${o.rounds} rounds on ${o.server}`);
408+ console.log(`\n### Stage ${name}\n\n${SUMMARY_HEAD.join("\n")}\n${summaryRow(r)}\n\n${latencyTable(r)}\n`);
411+ `Stopped after stage ${name}: errors ${(r.errorRate * 100).toFixed(2)}%, projects made ${r.projectsMade} of ${r.projects}.`,
425+ latencyMs: { publish: r.latencyMs.publish, record: r.latencyMs.record, sync: r.latencyMs.sync },
437+ writeFileSync(join(o.out, `${o.prefix}-ramp.json`), `${JSON.stringify(summary, null, "\t")}\n`);
438+ console.log(`\n## Ramp ${o.prefix}\n\n${SUMMARY_HEAD.join("\n")}\n${rows.map(summaryRow).join("\n")}\n`);
442+
- MCP
- compare on this site's /mcp
- CLI
- abso diff 39 318 server/scale/scale.mjs --json
- JSON
- /christopher/abso-core/compare/39..318?file=server%2Fscale%2Fscale.mjs&format=json