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