Keep proactive freshness scans off requests

This commit is contained in:
udo 2026-07-16 16:06:02 +00:00
parent ec07b5df22
commit 9dc9c61af6

View File

@ -645,22 +645,6 @@ 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);
@ -789,7 +773,6 @@ 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) ----------------------------------------------
@ -1638,11 +1621,13 @@ private:
return(1);
}
bool artifact_exists = file_exists_host(worker.unit_wasm_path(resolved));
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))
// The proactive compiler owns freshness while stale HTTP artifacts may be
// served. Keep source-graph scans off that request path; CLI/non-stale
// execution still checks synchronously and cold artifacts still compile.
bool stale = !can_serve_stale && artifact_exists && compiler_unit_needs_recompile(context, resolved, 0);
if(!artifact_exists || stale)
get_shared_unit(context, resolved);
size_t unit_index = 0;