Skip to content

One function contract, several engines

Accepted as direction; only part of it is built. The runtime tags (wasm, js, jvm), per-runtime routing and the POOL_LACKS_RUNTIME check exist. The wasmtime engine, the engine interface, the shared conformance suite and the jsv8 runtime are not yet implemented: the code today ships wazero only, and jsv8 is not a valid runtime tag.

2026-10-25.

Function authors write many functions, and they must not have to change source when the platform changes how it runs them. The same contract (control-plane protocol, guest ABI v1, describe document, invoke listener) has to survive a change of engine.

Measurements of the candidate engines showed a real trade-off:

  • wazero is pure Go, static and cross-compiles everywhere, so the development tool needs nothing extra. But it can only stop a runaway compiled guest by instrumenting every loop, which costs 4 to 10 times in speed.
  • wasmtime (Bytecode Alliance) was about twice as fast on the shipped JavaScript engine and can kill a runaway guest at a deadline through epoch interruption for a 15 to 20 per cent cost. From Go it needs cgo.
  • workerd (V8) was about fifty times faster on a realistic XML workload and has web-standard APIs, but it is a large separate C++ process, has no per-call CPU limit in its open-source build, and a heap overrun aborts every call in the process.
  1. One contract, several engines. The protocol, ABI v1 and invoke listener do not change. An engine is an implementation detail of a runner.
  2. The development tool runs wazero, so developers need nothing beyond the single binary.
  3. Deployed Linux runners run wasmtime through the same contract, as an engine interface inside the existing Go runner with wasmtime behind a build tag. The Go runner already implements the whole ABI host, so the ABI exists once and both engines run it. cgo is confined to the Linux server image build.
  4. A V8 runtime is added only when a function needs it. A function declares the runtime it needs (jsv8). It is deployed only to pools whose runners advertise it; otherwise promotion is refused with POOL_LACKS_RUNTIME. It never falls back silently.
  5. A function’s runtime is fixed. JavaScript functions default to js; whether js runs on wazero or wasmtime is the runner’s business.
  6. A shared conformance suite runs the same guest tests against every engine, so a difference between engines is a bug or a documented exception.
  7. Compiling TypeScript straight to Wasm is not pursued yet: it is much faster, but common libraries do not run on it.

The owner chose not to wait for wide adoption of the better engine; the risk is managed by the conformance suite, not by deferring.

Good:

  • Function source and the published describe document are independent of the engine.
  • Developers keep a zero-dependency local loop.
  • Deployed capacity can roughly double without a function change, and runaway compiled guests can be killed at their deadline.
  • Expensive V8 capacity is bought only when a function earns it.

Bad:

  • Two or three engines can drift. The conformance suite is the mitigation, and until it exists the drift risk is open.
  • The deployed image needs a C toolchain and cgo, unlike the pure-Go development build.
  • Operators may eventually run more than one runner kind and must size each.
Alternative Why not
wazero everywhere Simple, but half the speed and no cheap way to kill a runaway compiled guest.
A separate Rust runner with wasmtime Keeps cgo out, but re-implements the whole ABI host. Kept as the fallback if the Go wasmtime spike fails.
V8 (workerd) for all JavaScript Fastest, but a large extra process per OS, one core per process and no per-call CPU limit. Used only on demand.
Choose per function at publish time by speed The runtime is fixed per function, so promotion stays predictable.