Procedure Runtime#
The procedure runtime hosts Mudu Procedures inside the database process. It loads WebAssembly component modules, binds them to the kernel’s syscall surface, and executes procedure calls under kernel control.
Design#
The runtime is passive: it does not define its own scheduler or execution policy. The kernel decides when and where a procedure runs, and the runtime provides the execution container.
A typical invocation flow:
The kernel receives a procedure invocation request.
The kernel routes the request to the worker that owns the target partition.
The worker’s runtime loads the app/module if it is not already resident.
The runtime calls the exported procedure function with the session
OIDand user arguments.Inside the procedure, database operations trap into the kernel through the syscall interface.
The kernel applies transaction, scheduling, and consistency rules to each syscall.
When the procedure returns, the kernel commits or rolls back the transaction and returns the result.
Synchronous source, asynchronous execution#
Developers write procedures using synchronous-looking APIs (sys_interface::sync_api). At build time, the mtp transpiler can rewrite blocking syscalls into async-compatible forms suitable for the runtime’s continuation-driven executor.
This means:
Procedure authors keep a sequential programming model.
The runtime still yields while waiting for I/O or remote RPCs.
The same source can run interactively during development and be deployed as a stored procedure.
Syscall boundary#
Procedures access database state through a compact syscall set:
Session:
mudu_open,mudu_closeSQL:
mudu_query,mudu_command,mudu_batchKV:
mudu_get,mudu_put,mudu_range
Each syscall carries the session OID so the kernel can enforce transactional and scheduling context.
Use cases#
This model suits applications that need:
strong consistency inside a single procedure boundary,
low-latency business logic close to the data,
data-local execution that avoids repeated client-server round trips.
See Mudu Procedure for the programming model, System Call Reference for the syscall API, and WebAssembly Integration for the component runtime details.