Skip to content

Commit 8a580fd

Browse files
committed
computer: raise the JavaScript backend default limits
The starting defaults were tuned conservatively and proved too tight in practice. Raise the execution timeout ceiling to three minutes and the default to sixty seconds, the source and input byte ceilings to one mebibyte each, the retention window to sixty minutes, the concurrent execution ceiling to twenty-four, and the concurrent capability call ceiling to thirty-two. Update the backend documentation to match and keep the concurrency-cap test pinned to a single execution so it still exercises the ceiling.
1 parent 9e57a2b commit 8a580fd

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

docs/17_isolate_javascript.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const workspace = new Workspace({
1414
loader: env.LOADER,
1515
root: "/workspace",
1616
access: "read-write",
17-
defaultTimeoutMs: 10_000,
18-
maxTimeoutMs: 30_000,
17+
defaultTimeoutMs: 60_000,
18+
maxTimeoutMs: 180_000,
1919
globalOutbound: null,
2020
modules: {
2121
"math-kit": `export const double = value => value * 2;`,
@@ -81,11 +81,11 @@ Workspace parses the graph before loading the Worker, confines every durable pat
8181

8282
## Execution limits and retention
8383

84-
The backend admits one execution at a time by default. A concurrent start fails with `EEXEC_BUSY` instead of creating an unbounded number of Dynamic Workers. Set `maxConcurrentExecutions` only after measuring the Durable Object and Worker Loader limits for the deployment.
84+
The backend admits up to twenty-four executions at a time by default. A concurrent start past that ceiling fails with `EEXEC_BUSY` instead of creating an unbounded number of Dynamic Workers. Adjust `maxConcurrentExecutions` after measuring the Durable Object and Worker Loader limits for the deployment.
8585

8686
Each execution also bounds log events, active event subscribers, directory entries per read, concurrent and total capability calls, and cumulative capability request and response bytes. The corresponding `maxLogEvents`, `maxExecutionSubscribers`, `maxDirectoryEntries`, and `max*Capability*` options may be lowered for public workloads. Directory reads apply their limit in SQLite before materializing rows. Requests are checked inside the isolate before Workers RPC and again by the host.
8787

88-
Completed execution records remain available for replay for five minutes by default. The backend also keeps at most 100 completed records. Configure these bounds with `retentionMs` and `maxRetainedExecutions`. Completed records leave the in-memory active set immediately; replay reads them from SQLite.
88+
Completed execution records remain available for replay for sixty minutes by default. The backend also keeps at most 100 completed records. Configure these bounds with `retentionMs` and `maxRetainedExecutions`. Completed records leave the in-memory active set immediately; replay reads them from SQLite.
8989

9090
Cancellation stops new host capability calls, disposes the Dynamic Worker, and waits for host calls that were already accepted. Exit 130 is published only after those calls settle. Normal completion uses the same drain rule, so an unawaited capability call cannot mutate the workspace after exit 0.
9191

packages/computer/src/backends/worker-javascript/worker-javascript.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ describe("WorkerJavaScriptBackend", () => {
384384
waitUntil,
385385
backends: [
386386
new WorkerJavaScriptBackend({
387+
maxConcurrentExecutions: 1,
387388
loader: {
388389
load() {
389390
return {

packages/computer/src/backends/worker-javascript/worker-javascript.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ export class WorkerJavaScriptBackend implements WorkspaceModuleBackend {
144144

145145
constructor(options: WorkerJavaScriptBackendOptions) {
146146
this.id = options.id ?? "worker-javascript";
147-
const maxTimeoutMs = options.maxTimeoutMs ?? 30_000;
148-
const defaultTimeoutMs = options.defaultTimeoutMs ?? Math.min(10_000, maxTimeoutMs);
147+
const maxTimeoutMs = options.maxTimeoutMs ?? 180_000;
148+
const defaultTimeoutMs = options.defaultTimeoutMs ?? Math.min(60_000, maxTimeoutMs);
149149
assertPositiveFinite(maxTimeoutMs, "maxTimeoutMs");
150150
assertPositiveFinite(defaultTimeoutMs, "defaultTimeoutMs");
151-
assertPositiveFinite(options.maxSourceBytes ?? 256 * 1024, "maxSourceBytes");
152-
assertPositiveFinite(options.maxInputBytes ?? 256 * 1024, "maxInputBytes");
151+
assertPositiveFinite(options.maxSourceBytes ?? 1024 * 1024, "maxSourceBytes");
152+
assertPositiveFinite(options.maxInputBytes ?? 1024 * 1024, "maxInputBytes");
153153
assertPositiveFinite(options.maxStdinBytes ?? 256 * 1024, "maxStdinBytes");
154154
assertPositiveFinite(options.maxEnvBytes ?? 1024 * 1024, "maxEnvBytes");
155155
assertPositiveFinite(options.maxResultBytes ?? 1024 * 1024, "maxResultBytes");
@@ -158,7 +158,7 @@ export class WorkerJavaScriptBackend implements WorkspaceModuleBackend {
158158
assertPositiveFinite(options.maxCapabilityBytes ?? 1024 * 1024, "maxCapabilityBytes");
159159
assertPositiveFinite(options.maxHostCallMs ?? maxTimeoutMs, "maxHostCallMs");
160160
assertPositiveInteger(
161-
options.maxConcurrentCapabilityCalls ?? 16,
161+
options.maxConcurrentCapabilityCalls ?? 32,
162162
"maxConcurrentCapabilityCalls",
163163
);
164164
assertPositiveInteger(options.maxCapabilityCalls ?? 256, "maxCapabilityCalls");
@@ -171,9 +171,9 @@ export class WorkerJavaScriptBackend implements WorkspaceModuleBackend {
171171
"maxCapabilityResponseBytes",
172172
);
173173
assertPositiveInteger(options.maxDirectoryEntries ?? 1024, "maxDirectoryEntries");
174-
assertPositiveInteger(options.maxConcurrentExecutions ?? 1, "maxConcurrentExecutions");
174+
assertPositiveInteger(options.maxConcurrentExecutions ?? 24, "maxConcurrentExecutions");
175175
assertPositiveInteger(options.maxExecutionSubscribers ?? 8, "maxExecutionSubscribers");
176-
assertPositiveFinite(options.retentionMs ?? 5 * 60_000, "retentionMs");
176+
assertPositiveFinite(options.retentionMs ?? 60 * 60_000, "retentionMs");
177177
assertPositiveInteger(options.maxRetainedExecutions ?? 100, "maxRetainedExecutions");
178178
if ((options.maxCapabilityBytes ?? 1024 * 1024) < 256) {
179179
throw new Error("WorkerJavaScriptBackend maxCapabilityBytes must be at least 256 bytes.");
@@ -191,23 +191,23 @@ export class WorkerJavaScriptBackend implements WorkspaceModuleBackend {
191191
access: options.access ?? "read-write",
192192
defaultTimeoutMs,
193193
maxTimeoutMs,
194-
maxSourceBytes: options.maxSourceBytes ?? 256 * 1024,
195-
maxInputBytes: options.maxInputBytes ?? 256 * 1024,
194+
maxSourceBytes: options.maxSourceBytes ?? 1024 * 1024,
195+
maxInputBytes: options.maxInputBytes ?? 1024 * 1024,
196196
maxStdinBytes: options.maxStdinBytes ?? 256 * 1024,
197197
maxEnvBytes: options.maxEnvBytes ?? 1024 * 1024,
198198
maxResultBytes: options.maxResultBytes ?? 1024 * 1024,
199199
maxLogBytes: options.maxLogBytes ?? 256 * 1024,
200200
maxLogEvents: options.maxLogEvents ?? 1024,
201201
maxCapabilityBytes: options.maxCapabilityBytes ?? 1024 * 1024,
202202
maxHostCallMs: options.maxHostCallMs ?? maxTimeoutMs,
203-
maxConcurrentCapabilityCalls: options.maxConcurrentCapabilityCalls ?? 16,
203+
maxConcurrentCapabilityCalls: options.maxConcurrentCapabilityCalls ?? 32,
204204
maxCapabilityCalls: options.maxCapabilityCalls ?? 256,
205205
maxCapabilityRequestBytes: options.maxCapabilityRequestBytes ?? 8 * 1024 * 1024,
206206
maxCapabilityResponseBytes: options.maxCapabilityResponseBytes ?? 8 * 1024 * 1024,
207207
maxDirectoryEntries: options.maxDirectoryEntries ?? 1024,
208-
maxConcurrentExecutions: options.maxConcurrentExecutions ?? 1,
208+
maxConcurrentExecutions: options.maxConcurrentExecutions ?? 24,
209209
maxExecutionSubscribers: options.maxExecutionSubscribers ?? 8,
210-
retentionMs: options.retentionMs ?? 5 * 60_000,
210+
retentionMs: options.retentionMs ?? 60 * 60_000,
211211
maxRetainedExecutions: options.maxRetainedExecutions ?? 100,
212212
compatibilityDate,
213213
compatibilityFlags: options.compatibilityFlags ?? ["nodejs_compat"],

0 commit comments

Comments
 (0)