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 278 to 318

Compare

+213 −0 in 3 places
Lines 31–39 at 318 (were 31–36 at 278)
3131 write: false,
3232 outfile: OUT,
3333 logLevel: "warning",
34+ // Local projects run the open server's code in the client (client/src/local-store.ts); its Durable Object
35+ // base class comes from the Workers runtime, so the bundle gets the client's stand-in.
36+ alias: { "cloudflare:workers": "./client/src/durable-object-stand-in.ts" },
3437 // A bundled CommonJS package (yaml) calls require("process") lazily, which an ES module bundle
3538 // can't do without a real require.
3639 banner: {
new file, 123 lines
1+// Time and memory of a local project's commands (abso init --local) on a small and a large history:
2+//
3+// node scripts/local-measure.ts [versions ...] (default: 20 1000)
4+//
5+// Each history is built in this process through the client's main(); then every command is run as its own
6+// `node client/abso.ts` process, the way a person or an agent runs it, five times. It prints the median and slowest
7+// wall time, and the largest peak memory (maxRSS) of those runs, with the store's size on disk.
8+
9+import { spawnSync } from "node:child_process";
10+import { mkdtempSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
11+import { tmpdir } from "node:os";
12+import { join, resolve } from "node:path";
13+import { fileURLToPath, pathToFileURL } from "node:url";
14+import { main } from "../client/src/main.ts";
16+const ROOT = resolve(fileURLToPath(new URL("..", import.meta.url)));
17+const ENTRY = join(ROOT, "client", "abso.ts");
18+const FILES = 40;
19+const RUNS = 5;
21+const sizes = process.argv.slice(2).map(Number);
22+const histories = sizes.length > 0 ? sizes : [20, 1000];
24+function sizeOf(dir: string): number {
25+ let total = 0;
26+ for (const name of readdirSync(dir)) {
27+ const path = join(dir, name);
28+ const s = statSync(path);
29+ total += s.isDirectory() ? sizeOf(path) : s.size;
30+ }
31+ return total;
32+}
34+const lines = (file: number, version: number) =>
35+ Array.from({ length: 30 }, (_, i) =>
36+ i === version % 30 ? `line ${i} of file ${file}, version ${version}` : `line ${i} of file ${file}`,
37+ )
38+ .join("\n")
39+ .concat("\n");
41+async function build(versions: number): Promise<{ store: string; alice: string; bob: string }> {
42+ const store = mkdtempSync(join(tmpdir(), "abso-measure-store-"));
43+ const alice = mkdtempSync(join(tmpdir(), "abso-measure-alice-"));
44+ const bob = mkdtempSync(join(tmpdir(), "abso-measure-bob-"));
45+ const env = { ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" };
46+ const run = async (cwd: string, ...argv: string[]) => {
47+ const r = await main(argv, { cwd, env, write: () => {} });
48+ if (r.exit !== 0) throw new Error(`${argv.join(" ")}: ${r.stdout}${r.stderr}`);
49+ };
50+ for (let f = 0; f < FILES; f++) writeFileSync(join(alice, `f${f}.txt`), lines(f, 0));
51+ await run(alice, "init", "--local", "--project", "measure", "--agent", "alice", "--as-is");
52+ for (let v = 1; v < versions; v++) {
53+ // Each version changes three files, as a small piece of work does.
54+ for (const f of [v % FILES, (v * 7) % FILES, (v * 13) % FILES])
55+ writeFileSync(join(alice, `f${f}.txt`), lines(f, v));
56+ await run(alice, "push", "-m", `Version ${v}`);
57+ }
58+ await run(bob, "join", "measure", "--local", "--agent", "bob", "--dir", bob);
59+ return { store, alice, bob };
60+}
62+function measure(cwd: string, store: string, argv: string[]): { median: number; slowest: number; rss: number } {
63+ const times: number[] = [];
64+ let rss = 0;
65+ const preload = join(tmpdir(), `abso-measure-rss-${process.pid}.mjs`);
66+ const out = join(tmpdir(), `abso-measure-rss-${process.pid}.json`);
67+ writeFileSync(
68+ preload,
69+ `import { writeFileSync } from "node:fs";\nprocess.on("exit", () => writeFileSync(${JSON.stringify(out)}, String(process.resourceUsage().maxRSS)));\n`,
70+ );
71+ for (let i = 0; i < RUNS; i++) {
72+ const started = performance.now();
73+ const r = spawnSync(process.execPath, ["--import", pathToFileURL(preload).href, ENTRY, ...argv], {
74+ cwd,
75+ env: { ...process.env, ABSO_STORE: store, ABSO_SERVERS_FILE: "no-servers.json" },
76+ encoding: "utf8",
77+ });
78+ times.push(performance.now() - started);
79+ if (r.status !== 0 && argv[0] !== "push") throw new Error(`${argv.join(" ")}: ${r.stdout}${r.stderr}`);
80+ rss = Math.max(
81+ rss,
82+ Number(
83+ spawnSync(
84+ process.execPath,
85+ ["-e", `process.stdout.write(require("fs").readFileSync(${JSON.stringify(out)}, "utf8"))`],
86+ { encoding: "utf8" },
87+ ).stdout,
88+ ),
89+ );
90+ }
91+ times.sort((a, b) => a - b);
92+ return { median: times[Math.floor(RUNS / 2)]!, slowest: times[RUNS - 1]!, rss };
93+}
95+const kb = (n: number) => `${(n / 1024).toFixed(0)} MB`;
96+const ms = (n: number) => `${n.toFixed(0)} ms`;
97+console.log(
98+ `Node ${process.versions.node}, ${FILES} files of 30 lines, three files changed per version, ${RUNS} runs each.`,
99+);
100+console.log("history | command | median | slowest | peak memory");
101+for (const versions of histories) {
102+ const started = performance.now();
103+ const { store, alice, bob } = await build(versions);
104+ const built = performance.now() - started;
105+ const steps: [string, string, string[]][] = [
106+ ["status", alice, ["status"]],
107+ ["log", alice, ["log"]],
108+ ["blame", alice, ["blame", "f0.txt"]],
109+ ["pull (no change)", bob, ["pull"]],
110+ ["record + push", alice, ["push", "-m", "One more"]],
111+ ];
112+ for (const [name, cwd, argv] of steps) {
113+ if (argv[0] === "push") writeFileSync(join(cwd, "f1.txt"), lines(1, versions + Math.random()));
114+ const m = measure(cwd, store, argv);
115+ console.log(
116+ `${String(versions).padStart(5)} v | ${name.padEnd(20)} | ${ms(m.median).padStart(8)} | ${ms(m.slowest).padStart(8)} | ${kb(m.rss)}`,
117+ );
118+ }
119+ console.log(
120+ `${String(versions).padStart(5)} v | store on disk ${(sizeOf(store) / 1048576).toFixed(1)} MB, built in-process in ${(built / 1000).toFixed(1)} s`,
121+ );
122+ for (const d of [store, alice, bob]) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
123+}
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 278 318 scripts --json
JSON
/christopher/abso-core/compare/278..318?file=scripts&format=json