Cache component freshness probes

This commit is contained in:
udo 2026-07-16 15:27:59 +00:00
parent dc5ccee805
commit ec07b5df22

View File

@ -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<WasmUnitModule> unit_module(const String& source_path, String& error)
{
String wasm_path = unit_wasm_path(source_path);
@ -773,6 +789,7 @@ private:
}
std::map<String, std::shared_ptr<WasmUnitModule>> module_cache;
std::map<String, std::pair<std::chrono::steady_clock::time_point, bool>> 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))