Cache immutable Wasm server configuration encoding

This commit is contained in:
udo
2026-07-18 03:43:44 +00:00
parent a043fb8fc7
commit 516ed94032
6 changed files with 134 additions and 23 deletions
+12 -8
View File
@@ -87,9 +87,11 @@ the boundary).
children yielding `const DValue&`.
- The request context (`params`/`get`/`post`/`cookies`/`session`, the raw body
`in`, and—for WS—the connection context) is marshalled into a single `ctx`
DValue, UCEB-encoded, and handed to the workspace. The response (body,
headers, status, and any `meta` such as `ws_commands`) comes back the same
way.
DValue and UCEB-encoded. Immutable server configuration is UCEB-encoded once
per worker as a flat string map; both byte ranges are written into one guest
buffer. The guest decodes the flat map directly into its fresh `Server` and
the dynamic tree into its fresh `Request`. The response (body, headers,
status, and any `meta` such as `ws_commands`) comes back as UCEB.
See [`docs/wasm-phase1-dvalue-abi.md`](wasm-phase1-dvalue-abi.md) for the wire
format details.
@@ -160,10 +162,11 @@ drops one empty workspace. This preserves Wasmtime's fork boundary while
preventing the first request assigned to each worker from paying engine, linker,
or pre-instantiation startup.
Server configuration is immutable by that point. The worker therefore retains
one native `DValue` view of it; each request's temporary context tree references
that view while UCEB is encoded, avoiding a repeated native tree copy. The guest
still decodes the bytes into its fresh request tree. Request parameters, body,
cookies, session, call data, and response state are never retained this way.
one native `DValue` view and one UCEB encoding of it. Each request transfers
those cached bytes and the guest decodes the flat scalar map directly into its
fresh `Server`, avoiding both repeated native encoding and an intermediate guest
`DValue` tree. Request parameters, body, cookies, session, call data, and
response state are never retained this way.
Startup duration or failure is written to the service log. The serialized core
module lives in the configured writable cache root rather than beside the
possibly root-owned deployed `core.wasm`; freshness still uses the deployed
@@ -285,7 +288,8 @@ request rather than being deep-copied twice; the historical by-value
artifacts stay ABI-compatible. `request_perf()` subdivides birth into policy,
import materialization, core instantiation, export/table lookup, and initialization,
and context transfer into bytes, host encode, guest allocation/write,
guest decode/application, and free.
guest decode/application, and free. The byte profile separately reports the
worker-cached server-configuration portion.
### Task callbacks and workspace lifetime