Skip canonicalization for recent source entries
This commit is contained in:
parent
9beec0dd03
commit
914cf17f23
@ -64,6 +64,18 @@ const u64 UCE_UNIT_SOURCE_SIGNATURE_CACHE_MAX = 4096;
|
||||
std::mutex unit_source_signature_cache_mutex;
|
||||
std::map<String, UnitSourceSignatureEntry> unit_source_signature_cache;
|
||||
|
||||
bool compiler_recent_unit_source_entry(String file_name, UnitSourceSignatureEntry& entry)
|
||||
{
|
||||
auto checked_at = std::chrono::steady_clock::now();
|
||||
std::lock_guard<std::mutex> lock(unit_source_signature_cache_mutex);
|
||||
auto cached = unit_source_signature_cache.find(file_name);
|
||||
if(cached == unit_source_signature_cache.end() ||
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(checked_at - cached->second.checked_at).count() >= 1000)
|
||||
return(false);
|
||||
entry = cached->second;
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool compiler_jit_compile_on_request_enabled(Request* context)
|
||||
{
|
||||
if(!context || !context->server)
|
||||
@ -151,11 +163,9 @@ UnitSourceSignatureEntry compiler_unit_source_entry(String file_name, bool allow
|
||||
auto checked_at = std::chrono::steady_clock::now();
|
||||
if(allow_recent_stat)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(unit_source_signature_cache_mutex);
|
||||
auto cached = unit_source_signature_cache.find(file_name);
|
||||
if(cached != unit_source_signature_cache.end() &&
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(checked_at - cached->second.checked_at).count() < 1000)
|
||||
return(cached->second);
|
||||
UnitSourceSignatureEntry cached;
|
||||
if(compiler_recent_unit_source_entry(file_name, cached))
|
||||
return(cached);
|
||||
}
|
||||
struct stat info;
|
||||
UnitSourceSignatureEntry entry;
|
||||
@ -189,14 +199,21 @@ 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)
|
||||
{
|
||||
String normalized = path_real(file_name);
|
||||
if(normalized == "")
|
||||
normalized = file_name;
|
||||
String normalized = file_name;
|
||||
UnitSourceSignatureEntry entry;
|
||||
bool recent = allow_recent_stat && compiler_recent_unit_source_entry(normalized, entry);
|
||||
if(!recent)
|
||||
{
|
||||
normalized = path_real(file_name);
|
||||
if(normalized == "")
|
||||
normalized = file_name;
|
||||
}
|
||||
if(visited.find(normalized) != visited.end())
|
||||
return;
|
||||
visited.insert(normalized);
|
||||
|
||||
UnitSourceSignatureEntry entry = compiler_unit_source_entry(normalized, allow_recent_stat);
|
||||
if(!recent)
|
||||
entry = compiler_unit_source_entry(normalized, allow_recent_stat);
|
||||
signature += normalized + ":" + entry.content_hash + (entry.readable ? String("") : String(":unreadable")) + "\n";
|
||||
for(String loaded : entry.loaded_paths)
|
||||
compiler_append_unit_source_signature(loaded, visited, signature, allow_recent_stat);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user