diff --git a/src/wasm/worker.cpp b/src/wasm/worker.cpp index 87ad56c..0dadf25 100644 --- a/src/wasm/worker.cpp +++ b/src/wasm/worker.cpp @@ -645,6 +645,22 @@ public: return(cfg.cache_root + source_path + ".wasm"); } + bool component_unit_needs_recompile(Request* context, const String& source_path, bool can_serve_stale) + { + if(!can_serve_stale) + return(compiler_unit_needs_recompile(context, source_path, 0)); + // The proactive compiler owns stale HTTP publication. Bound its full + // source-graph signature scan per worker instead of repeating it at every + // component boundary; CLI and non-stale requests keep immediate checks. + auto now = std::chrono::steady_clock::now(); + auto cached = component_freshness.find(source_path); + if(cached != component_freshness.end() && now - cached->second.first < std::chrono::seconds(1)) + return(cached->second.second); + bool stale = compiler_unit_needs_recompile(context, source_path, 0); + component_freshness[source_path] = {now, stale}; + return(stale); + } + std::shared_ptr unit_module(const String& source_path, String& error) { String wasm_path = unit_wasm_path(source_path); @@ -773,6 +789,7 @@ private: } std::map> module_cache; + std::map> component_freshness; }; // ---- workspace (per request) ---------------------------------------------- @@ -1621,8 +1638,8 @@ private: return(1); } - bool stale = compiler_unit_needs_recompile(context, resolved, 0); bool can_serve_stale = compiler_request_can_serve_stale_artifact(context); + bool stale = worker.component_unit_needs_recompile(context, resolved, can_serve_stale); if(stale && can_serve_stale) compiler_prioritize_unit(context, resolved); if(!file_exists_host(worker.unit_wasm_path(resolved)) || (stale && !can_serve_stale))