Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion scripts/performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ bun run test:performance --list
bun run test:performance --workload shared.long-line --samples 100 \
--output /tmp/tale-long-lines.json

# Measure output journal writes and repeated late reconnects separately.
bun run test:performance --workload daemon.journal-write \
--workload daemon.journal-reconnect --samples 100 \
--output /tmp/tale-journals.json

# Optional local SAST workload: requires the pinned binary already cached by lint:sast.
bun run test:performance --workload tools.opengrep --samples 3 \
--output /tmp/tale-opengrep.json
Expand All @@ -61,7 +66,7 @@ send authorization headers, measure browser rendering, or inspect server RSS.
| Shared process utilities | 100,000 lines into a bounded ring; 16 MiB unterminated line in 4 KiB chunks | Other utilities and Postgres transaction/retry contention |
| Platform engine/telemetry | Cold/cached validation of 100-item automation inputs; 1000 bounded metric updates and worker spans with tracing disabled/enabled, on Node | API/worker/knowledge/chat with real Postgres, storage and controlled model responses; authenticated UI |
| Sandbox spawner | 1000 exec boundary validations with 128 environment values; 1000-event SSE burst | Docker/Kubernetes provisioning, concurrent session admission, image warmup |
| Sandbox daemon/runtime | Real Node process output, 1 MiB stream and bounded replay | Linux subreaper, sustained reconnects, container resource ceilings and image-only document dependencies |
| Sandbox daemon/runtime | Real Node process output and 1 MiB replay; 16,000-record journal writes; 20 late reconnects per sample requesting the last ten records | Linux subreaper, sustained concurrent reconnects, container resource ceilings and image-only document dependencies |
| AI gateway | Read/validate/decrypt 100 file-backed accounts and atomic update | OAuth, provider refresh, controlled credential-pool traffic |
| UI and marketing UI | 100-button SSR, including marketing wrappers | Browser layout/hydration, all other components and animation |
| Web/docs/UI docs | Shared server: 100 HTTP requests in batches of ten; cold/cached 250-page SEO artifact bursts | Service content/search/build/prerender and browser navigation; shared code is labelled `shared-library-only` |
Expand Down Expand Up @@ -110,6 +115,15 @@ is useful context, **not proof of a leak or a leak-free service**. The shared HT
worker includes both server and client allocations. Compare like-for-like
reports; do not claim a speedup from a contended run against an idle run.

The journal workloads use actual temporary, unlinked files. Write samples include
record encoding, backpressure, drain, a verified ten-record suffix replay and
descriptor closure. Reconnect samples reuse a completed 16,000-record journal
prepared before timing; each sample makes 20 sequential attachments and checks
every returned sequence, payload and replay marker. Setup still contributes to
process memory measurements. These workloads exercise Node and the host
filesystem, without a container network or model provider; their batch timings
do not predict complete agent-run latency.

## Completing a deployment profile

Build every shipping frontend with its workspace `build` command without Turbo
Expand Down
31 changes: 22 additions & 9 deletions scripts/performance/inventory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';

import { z } from 'zod';

import { root } from './workloads';

const rootManifestSchema = z.object({ workspaces: z.array(z.string()) });
const workspaceManifestSchema = z.object({ name: z.string() });

interface Coverage {
workloads: string[];
shared?: boolean;
Expand Down Expand Up @@ -32,12 +37,20 @@ const coverage: Record<string, Coverage> = {
'Container admission, image warmup, Kubernetes/Docker provisioning and concurrent session capacity need a disposable runtime host.',
},
'@tale/sandbox-runtime-daemon': {
workloads: ['daemon.exec-replay'],
workloads: [
'daemon.exec-replay',
'daemon.journal-write',
'daemon.journal-reconnect',
],
remaining:
'Host exec/replay only; Linux subreaper, long-running reconnect load and container resource limits need the runtime image.',
'Host exec/replay and synthetic journal bursts only; Linux subreaper, long-running reconnect load and container resource limits need the runtime image.',
},
'@tale/sandbox-runtime': {
workloads: ['daemon.exec-replay'],
workloads: [
'daemon.exec-replay',
'daemon.journal-write',
'daemon.journal-reconnect',
],
shared: true,
remaining:
'Daemon code measured on host; runtime image, agent CLIs, document toolchain and Linux process isolation require Docker and image builds.',
Expand Down Expand Up @@ -141,9 +154,9 @@ export async function workspaceInventory(
measured: ReadonlySet<string>,
httpWorkspaces: ReadonlySet<string>,
) {
const manifest = JSON.parse(
await readFile(resolve(root, 'package.json'), 'utf8'),
) as { workspaces: string[] };
const manifest = rootManifestSchema.parse(
JSON.parse(await readFile(resolve(root, 'package.json'), 'utf8')),
);
const files = new Set<string>();
for (const pattern of manifest.workspaces) {
for await (const file of new Bun.Glob(`${pattern}/package.json`).scan({
Expand All @@ -153,9 +166,9 @@ export async function workspaceInventory(
}
const workspaces = await Promise.all(
[...files].sort().map(async (path) => {
const { name } = JSON.parse(
await readFile(resolve(root, path), 'utf8'),
) as { name: string };
const { name } = workspaceManifestSchema.parse(
JSON.parse(await readFile(resolve(root, path), 'utf8')),
);
const entry = coverage[name];
if (!entry)
throw new Error(
Expand Down
104 changes: 104 additions & 0 deletions scripts/performance/journal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import assert from 'node:assert/strict';
import { mkdtemp, rm } from 'node:fs/promises';
import { join } from 'node:path';

import {
ExecJournal,
JournalBudget,
} from '../../services/sandbox-runtime/daemon/src/exec-journal.ts';
import type { Workload } from './workloads.ts';

const RECORDS = 16_000;
const RECONNECTS = 20;
const SUFFIX = 10;
const payload = Buffer.alloc(384, 'x').toString('base64');

/** Real unlinked journal files, without a child process or transport fixture. */
export async function prepareJournalWorkload(
id: string,
fixtureRoot: string,
): Promise<Workload> {
const directory = await mkdtemp(join(fixtureRoot, 'tale-journal-'));
const budget = new JournalBudget();
let retained: ExecJournal | undefined;
let journalBytes = 0;
const populate = async () => {
let failure: string | undefined;
const journal = new ExecJournal(
budget,
() => {},
(reason) => {
failure = reason;
},
undefined,
directory,
);
retained = journal;
journalBytes = 0;
for (let seq = 1; seq <= RECORDS; seq++) {
const line = `${JSON.stringify({ t: 'stdout', b64: payload, seq })}\n`;
journalBytes += Buffer.byteLength(line);
if (!journal.append(line)) await journal.drain();
assert.equal(failure, undefined);
}
await journal.drain();
assert.equal(failure, undefined);
journal.finish();
return journal;
};
const replaySuffix = async (journal: ExecJournal) => {
let expectedSeq = RECORDS - SUFFIX + 1;
const markers: string[] = [];
await journal.replay((event) => {
if (event.t === 'replay-start' || event.t === 'replay-complete') {
markers.push(event.t);
if (event.t === 'replay-complete') {
assert.equal(event.throughSeq, RECORDS);
assert.equal(expectedSeq, RECORDS + 1);
}
return;
}
assert.equal(event.t, 'stdout');
if (event.t !== 'stdout') throw new Error('Unexpected journal event');
assert.equal(event.seq, expectedSeq++);
assert.equal(event.b64, payload);
}, RECORDS - SUFFIX);
assert.equal(expectedSeq, RECORDS + 1);
assert.deepEqual(markers, ['replay-start', 'replay-complete']);
};
const reconnect = id === 'daemon.journal-reconnect';
if (reconnect) await populate();
return {
operations: reconnect ? RECONNECTS : RECORDS,
unit: reconnect ? 'reconnects' : 'records',
description: reconnect
? '20 sequential reconnects at the last ten of 16,000 journal records; setup excluded, exact suffix and replay markers verified'
: 'Write and drain 16,000 journal records with 512-character base64 payloads, respecting backpressure; verify the final ten records and close the file',
async run() {
if (reconnect) {
assert.ok(retained);
for (let i = 0; i < RECONNECTS; i++) await replaySuffix(retained);
} else {
const journal = await populate();
try {
await replaySuffix(journal);
} finally {
await journal.dispose();
retained = undefined;
}
}
},
details: () => ({
journalRecords: RECORDS,
journalBytes,
payloadBytes: 384,
suffixRecords: SUFFIX,
reconnectsPerSample: reconnect ? RECONNECTS : 1,
scope: 'Host filesystem and Node journal only; no container or network',
}),
async cleanup() {
await retained?.dispose();
await rm(directory, { recursive: true, force: true });
},
};
}
8 changes: 7 additions & 1 deletion scripts/performance/workloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const workloadRuntimes = {
'sandbox.validation': 'bun',
'sandbox.sse': 'bun',
'daemon.exec-replay': 'node',
'daemon.journal-write': 'node',
'daemon.journal-reconnect': 'node',
'gateway.store': 'bun',
'ui.static-http': 'bun',
'ui.seo-cold': 'bun',
Expand All @@ -50,6 +52,10 @@ export async function prepareWorkload(
id: string,
fixtureRoot: string,
): Promise<Workload> {
if (id === 'daemon.journal-write' || id === 'daemon.journal-reconnect') {
const { prepareJournalWorkload } = await import('./journal.ts');
return prepareJournalWorkload(id, fixtureRoot);
}
if (id === 'tools.plop-scaffold' || id === 'tools.opengrep') {
const { prepareToolWorkload } = await import('./tooling.ts');
return prepareToolWorkload(id, root, fixtureRoot);
Expand Down Expand Up @@ -208,7 +214,7 @@ export async function prepareWorkload(
operations: 1,
unit: 'execs',
description:
'Real Node child outputs 1 MiB through runnerd then replays its bounded ring; host process reaping, no container',
'Real Node child outputs 1 MiB through runnerd then replays its bounded journal; host process reaping, no container',
async run() {
const execId = `performance-${sequence++}`;
let exited = false;
Expand Down
Loading