Repository navigation
perf(platform): evaluate automations faster — template fast path, scope views, runner pool - #4693
Merged
Merged
Conversation
Benches for what a run costs today: one item's templates beside small and large earlier outputs, the code runner warm and under CPU load, forty transforms through execute() with and without the record, and a durable loop of connector reads with its progress writes. Cases the engine cannot run yet are listed as todo.
A unit that is a path into the scope, a literal, or a path with a ?? or || fallback is planned once from its parse and read straight from the scope, answering exactly what the runner would: a JSON copy of the read. Any read it cannot be sure of (a missing base, an inherited member, a value a JSON copy would change) goes to the runner, which keeps its error text. Traced evaluations keep the runner, so probes and the run record are unchanged. A process-wide switch turns the fast path off; a seeded property holds it to the runner over 2,000 units.
…a copy A scope no longer copies the run's input and every earlier output on each step, item and condition; it is a view, since nothing in the engine writes to one: what crosses into the runner is serialized there, and what the fast path reads it copies. The server suites hand out frozen copies instead, so a write to a scope anywhere throws. One item's templates now cost the same beside 5 MB of earlier output as beside none, and forty transforms run four times faster.
A backend process now evaluates templates and transform bodies in up to AUTOMATION_RUNNER_PROCESSES runner processes (by default two for the api, and one per core but one, at most four, for a worker). Each is the supervised child one runner was. A process starts only when the others each hold two evaluations, one beyond the first retires after five idle minutes, and a kill fails only what its own process held. Waiting evaluations queue per organization, each stepper turn as its run's, and are served in turn. The five places that installed the runner now share one helper. Sixteen CPU-bound bodies take 77 ms on four processes against 309 ms on one.
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The first three slices of the faster automation engine. None of them changes what a run does; each makes it cheaper.
Benches (
perf.bench.ts,stepper.perf.bench.ts): what a run costs, with the cases the engine cannot run yet listed as todo. The baseline replaces the design's estimates. Itsexecute()figures did not reproduce: today's engine was 3–4× faster than estimated, and the per-step copy of the run's values was the dominant cost.Template fast path (
template-fast.ts): a{{ }}unit that is a path into the scope, a literal, or a path with a??/||fallback is planned once from its parse and read straight from the scope. It answers exactly what the runner would: a JSON copy of the read. Any read it cannot be sure of goes to the runner, which keeps its own error text:__proto__;Date, an object without a prototype, an array hole, an owntoJSON).Traced evaluations keep the runner, so probes and the run record are unchanged. A process-wide switch turns the fast path off.
Scope views (
execute/scope.ts): a step's scope is a view of the run's values, not a copy, since nothing in the engine writes to one. The server suites hand out frozen copies instead, so any write to a scope throws in tests.Runner pool (
runners/node-vm.ts,runners/tenant.ts,backend/lib/code-runner.ts):AUTOMATION_RUNNER_PROCESSESrunner processes per backend process. By default two for the api, and one per core but one, at most four, for a worker.Numbers (Apple M2 Max, Node 22.22)
execute(), 40 transforms, chain / independentProof
lint:links,lint:manual, knip.checkAutomations,checkAutomationRunLifecycle,checkAutomationTriggerDelivery,checkAutomationNodeRuns,checkAutomationAgentNode,checkAutomationStepDestroyPending,checkScheduledAgentStarts,checkInPlaceCompletionCycle,checkTaskAutomationOccupancy,checkWorkflowTurnReattach,checkMcpAuthoringParity,checkManagedAutomationConfiguration,checkTriggerPauseAfterFailuresandcheckEventScopeAndIsolation.AUTOMATION_RUNNER_PROCESSESis documented in.env.example, the backend README and the environment reference (EN/DE/FR).Follow-up: on the api, a request's evaluations still share one queue. Only the stepper names its tenant so far.