Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 175 to 318

Compare

+87 −0 in 1 place
new file, 87 lines
1+// A local project's store lock under load: 1, 4 and 16 writers pushing to one local project at once.
2+//
3+// node scripts/local-writers.ts [writers ...] (default: 1 4 16; PUSHES=10 pushes per writer)
4+//
5+// Each writer is its own agent, in its own folder, changing its own file, so nothing collides: what's measured is the
6+// store's lock (one SQLite write transaction per call). Every push is its own `node client/abso.ts push` process, as
7+// an agent runs it. It prints each push's wall time (median, 95th percentile, slowest), the pushes per second across
8+// all writers, and any push that failed.
9+
10+import { spawn } from "node:child_process";
11+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
12+import { tmpdir } from "node:os";
13+import { join, resolve } from "node:path";
14+import { fileURLToPath } from "node:url";
15+import { main } from "../client/src/main.ts";
17+const ROOT = resolve(fileURLToPath(new URL("..", import.meta.url)));
18+const ENTRY = join(ROOT, "client", "abso.ts");
19+const PUSHES = Number(process.env.PUSHES ?? 10);
20+const counts = process.argv.slice(2).map(Number);
22+function push(cwd: string, store: string, message: string): Promise<{ ms: number; ok: boolean; out: string }> {
23+ const started = performance.now();
24+ return new Promise((done) => {
25+ const child = spawn(process.execPath, [ENTRY, "push", "-m", message], {
26+ cwd,
27+ env: { ...process.env, ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" },
28+ });
29+ let out = "";
30+ child.stdout.on("data", (d) => {
31+ out += d;
32+ });
33+ child.stderr.on("data", (d) => {
34+ out += d;
35+ });
36+ child.on("close", (code) => done({ ms: performance.now() - started, ok: code === 0, out }));
37+ });
38+}
40+const pct = (sorted: number[], p: number) => sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * p))]!;
41+console.log(`Node ${process.versions.node}, ${PUSHES} pushes per writer, each writer its own agent and file.`);
42+console.log("writers | pushes | median | p95 | slowest | pushes/s | failed");
43+for (const writers of counts.length > 0 ? counts : [1, 4, 16]) {
44+ const store = mkdtempSync(join(tmpdir(), "abso-writers-store-"));
45+ const folders: string[] = [];
46+ const env = { ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" };
47+ const first = mkdtempSync(join(tmpdir(), "abso-writers-w0-"));
48+ writeFileSync(join(first, "readme.txt"), "writers\n");
49+ const init = await main(["init", "--local", "--project", "writers", "--agent", "w0", "--as-is"], {
50+ cwd: first,
51+ env,
52+ write: () => {},
53+ });
54+ if (init.exit !== 0) throw new Error(init.stdout + init.stderr);
55+ folders.push(first);
56+ for (let w = 1; w < writers; w++) {
57+ const dir = mkdtempSync(join(tmpdir(), `abso-writers-w${w}-`));
58+ const joined = await main(["join", "writers", "--local", "--agent", `w${w}`, "--dir", dir], {
59+ cwd: dir,
60+ env,
61+ write: () => {},
62+ });
63+ if (joined.exit !== 0) throw new Error(joined.stdout + joined.stderr);
64+ folders.push(dir);
65+ }
66+ const times: number[] = [];
67+ const failures: string[] = [];
68+ const started = performance.now();
69+ await Promise.all(
70+ folders.map(async (dir, w) => {
71+ for (let i = 0; i < PUSHES; i++) {
72+ writeFileSync(join(dir, `w${w}.txt`), `writer ${w}, push ${i}\n`);
73+ const r = await push(dir, store, `w${w} push ${i}`);
74+ times.push(r.ms);
75+ if (!r.ok) failures.push(`w${w} push ${i}: ${r.out.trim().split("\n").slice(-2).join(" / ")}`);
76+ }
77+ }),
78+ );
79+ const total = (performance.now() - started) / 1000;
80+ times.sort((a, b) => a - b);
81+ const ms = (n: number) => `${n.toFixed(0)} ms`.padStart(8);
82+ console.log(
83+ `${String(writers).padStart(7)} | ${String(times.length).padStart(6)} | ${ms(pct(times, 0.5))} | ${ms(pct(times, 0.95))} | ${ms(times.at(-1)!)} | ${(times.length / total).toFixed(1).padStart(8)} | ${failures.length}`,
84+ );
85+ for (const f of failures.slice(0, 5)) console.log(` ${f}`);
86+ for (const d of [store, ...folders]) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
87+}
MCP
compare on this site's /mcp
CLI
abso diff 175 318 scripts/local-writers.ts --json
JSON
/christopher/abso-core/compare/175..318?file=scripts%2Flocal-writers.ts&format=json