mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-12-05 22:39:19 +00:00
Snapshots before every call cost a full heap write per call (128 ms per call with 100k live objects, against 2 ms with the journal), and replay restarts as fast or faster except for compute-heavy scripts. Durable code mode is back to main's journal and replay, run through start() on djs. - durable: src/codemode, tests, spec 7.6 and README as on main (call.ts, snapshots, deliveries and parking are gone), keeping djs, TypeScript, namespace imports and the searchTools() hint. CODEMODE_MODULE_VERSION 3. - pi-codemode: start() is supported again (replay.ts, no deprecation). It numbers the calls it hands out 1, 2, ... (djs counts sync host calls too), lists the un-awaited calls of the last step in run.dropped, and takes modules and missingToolHint. begin()/resume()/save() stay. - p2: the code mode plugin drains its sandbox on reload and replays after a worker stop, as on main; CPU budget kept as CODEMODE_CPU_BUDGET (part of the fingerprint).
21 lines
1.1 KiB
TypeScript
21 lines
1.1 KiB
TypeScript
import { local } from "@p2/app/v1";
|
|
|
|
/**
|
|
* Heap cap of each script's djs VM. Keep it constant across restarts: the limit is part of the VM's fingerprint,
|
|
* which Durable records when a script starts, and a script interrupted by a restart resumes only on a VM with the same
|
|
* fingerprint. A changed limit makes every interrupted script end with "the sandbox changed" instead of resuming.
|
|
*/
|
|
export const CODEMODE_MEMORY_LIMIT_BYTES = 256 * 1024 * 1024;
|
|
|
|
/**
|
|
* CPU budget of each run of a script, about a minute of computing (`interruptBudget`; waiting on tools does not count).
|
|
* A replay after a restart runs with a budget of its own. Part of the fingerprint too: keep it constant.
|
|
*/
|
|
export const CODEMODE_CPU_BUDGET = 3_000_000;
|
|
|
|
/**
|
|
* The worker's code mode sandbox (host-internal): one per worker, closed when the plugin is removed or the worker
|
|
* stops; a reload opens a new one and drains the old one in the background (its scripts run on). Each running script
|
|
* holds one worker thread; closing aborts them.
|
|
*/
|
|
export const CodemodeRuntime = local("p2.codemode-runtime", { version: 2, params: {}, members: {} });
|