Deduplicate entry freshness filesystem work

This commit is contained in:
udo
2026-07-18 06:16:49 +00:00
parent 556025a779
commit f745ce9413
4 changed files with 32 additions and 7 deletions
+18 -6
View File
@@ -216,6 +216,11 @@ UnitSourceSignatureEntry compiler_unit_source_entry(String file_name, bool allow
void compiler_append_unit_source_signature(String file_name, std::set<String>& visited, String& signature, bool allow_recent_stat)
{
// The signature already deduplicates canonical files. Skip repeated exact
// load paths before resolving them again; distinct aliases are still
// canonicalized so symlink retargets remain visible on the next check.
if(visited.find(file_name) != visited.end())
return;
String normalized = file_name;
UnitSourceSignatureEntry entry;
bool recent = allow_recent_stat && compiler_recent_unit_source_entry(normalized, entry);
@@ -226,7 +231,11 @@ void compiler_append_unit_source_signature(String file_name, std::set<String>& v
normalized = file_name;
}
if(visited.find(normalized) != visited.end())
{
visited.insert(file_name);
return;
}
visited.insert(file_name);
visited.insert(normalized);
if(!recent)
@@ -244,9 +253,9 @@ String compiler_unit_source_signature(String file_name, bool allow_recent_stat =
return(gen_sha1(signature));
}
String compiler_unit_input_signature(Request* context, SharedUnit* su, bool allow_recent_source_stat = false)
String compiler_unit_input_signature(Request* context, SharedUnit* su, bool allow_recent_source_stat = false, bool source_exists_known = false)
{
if(!context || !su || !file_exists(su->file_name))
if(!context || !su || (!source_exists_known && !file_exists(su->file_name)))
return("");
String setup_template = context->server->config["COMPILER_SYS_PATH"] + "/" + context->server->config["SETUP_TEMPLATE"];
@@ -509,9 +518,12 @@ bool compiler_has_known_unit_cached(Request* context, String file_name)
SharedUnitFilesystemState inspect_shared_unit_filesystem(Request* context, SharedUnit* su, bool allow_recent_source_stat = false)
{
SharedUnitFilesystemState state;
state.source_exists = file_exists(su->file_name);
if(state.source_exists)
state.source_time = file_mtime(su->file_name);
struct stat source_stat;
if(stat(su->file_name.c_str(), &source_stat) == 0)
{
state.source_exists = true;
state.source_time = source_stat.st_mtime;
}
state.setup_template_time = file_mtime(
context->server->config["COMPILER_SYS_PATH"] + "/" +
context->server->config["SETUP_TEMPLATE"]
@@ -519,7 +531,7 @@ SharedUnitFilesystemState inspect_shared_unit_filesystem(Request* context, Share
state.compiler_abi_time = compiler_runtime_abi_time(context);
state.metadata_time = file_mtime(su->meta_file_name);
state.compile_output_time = file_mtime(su->compile_output_file_name);
state.current_input_signature = compiler_unit_input_signature(context, su, allow_recent_source_stat);
state.current_input_signature = compiler_unit_input_signature(context, su, allow_recent_source_stat, state.source_exists);
state.metadata_exists = (state.metadata_time != 0);
state.compile_output_exists = (state.compile_output_time != 0);
if(state.metadata_exists)