From 93c701c6c71a365ece1305cb5ce38e95d7a64d64 Mon Sep 17 00:00:00 2001 From: udo Date: Thu, 16 Jul 2026 21:10:09 +0000 Subject: [PATCH] Store serialized core in runtime cache --- docs/wasm-runtime-architecture.md | 5 ++++- src/wasm/worker.cpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/wasm-runtime-architecture.md b/docs/wasm-runtime-architecture.md index 5292659..e2a3850 100644 --- a/docs/wasm-runtime-architecture.md +++ b/docs/wasm-runtime-architecture.md @@ -140,7 +140,10 @@ changing core-first, unit-load-order symbol resolution. Each FastCGI child initializes its process-local Wasmtime engine after fork and before entering the accept loop. This preserves Wasmtime's fork boundary while preventing the first request assigned to each worker from paying engine startup. -Startup duration or failure is written to the service log. +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 +artifact's metadata. `request_perf()` reports worker module-cache hits and misses and divides a miss into artifact lookup, wasm read, custom-section parse, serialized-module diff --git a/src/wasm/worker.cpp b/src/wasm/worker.cpp index f27fe65..a2203ba 100644 --- a/src/wasm/worker.cpp +++ b/src/wasm/worker.cpp @@ -886,7 +886,9 @@ public: if(!wasm_parse_sections(bytes, core_dylink, abi_ignored, parse_error)) return("core module: " + parse_error); - String core_cached_path = cached_wasm_path(cfg.core_wasm_path); + // Deployed runtime sources can be root-owned while workers run unprivileged. + // Keep the derived serialized core in the configured writable cache root. + String core_cached_path = path_join(cfg.cache_root, ".uce-core.cwasm"); String compile_error; bool serialized_cache_hit = false; auto compiled_or_cached = load_or_compile_cached_module(engine, core_cached_path, cfg.core_wasm_path, bytes, compile_error, serialized_cache_hit);