Precompile native modules off request path
This commit is contained in:
+19
-7
@@ -1266,7 +1266,8 @@ void run_proactive_compiler()
|
||||
bool source_missing = false;
|
||||
auto retry_it = retry_after.find(file_name);
|
||||
bool retry_allowed = (retry_it == retry_after.end() || time_precise() >= retry_it->second);
|
||||
if(compiler_unit_needs_recompile(&background_context, file_name, &source_missing) && retry_allowed)
|
||||
bool needs_compile = compiler_unit_needs_recompile(&background_context, file_name, &source_missing);
|
||||
if(needs_compile && retry_allowed)
|
||||
proactive_compile_queue_push(compile_queue, file_name);
|
||||
if(source_missing)
|
||||
{
|
||||
@@ -1291,14 +1292,15 @@ void run_proactive_compiler()
|
||||
auto retry_it = retry_after.find(file_name);
|
||||
if(retry_it != retry_after.end() && time_precise() < retry_it->second)
|
||||
continue;
|
||||
bool failed = false;
|
||||
String wasm_path = server_state.config["BIN_DIRECTORY"] + file_name + ".wasm";
|
||||
if(compiler_unit_needs_recompile(&background_context, file_name, &source_missing))
|
||||
{
|
||||
printf("(i) proactive compile %s\n", file_name.c_str());
|
||||
auto su = get_shared_unit(&background_context, file_name);
|
||||
if(su && su->compiler_messages == "")
|
||||
retry_after.erase(file_name);
|
||||
else
|
||||
retry_after[file_name] = time_precise() + failure_retry_interval;
|
||||
failed = !su || su->compiler_messages != "";
|
||||
if(su)
|
||||
wasm_path = su->wasm_name;
|
||||
}
|
||||
else if(source_missing)
|
||||
{
|
||||
@@ -1306,10 +1308,20 @@ void run_proactive_compiler()
|
||||
compiler_untrack_known_unit(&background_context, file_name);
|
||||
retry_after.erase(file_name);
|
||||
}
|
||||
else
|
||||
if(!source_missing && !failed && wasm_serialized_module_needs_refresh(wasm_path))
|
||||
{
|
||||
retry_after.erase(file_name);
|
||||
printf("(i) proactive serialize %s\n", file_name.c_str());
|
||||
String serialize_error = wasm_serialize_module_artifact(wasm_path);
|
||||
if(serialize_error != "")
|
||||
{
|
||||
printf("(!) proactive serialize failed for %s: %s\n", file_name.c_str(), serialize_error.c_str());
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
if(!source_missing && failed)
|
||||
retry_after[file_name] = time_precise() + failure_retry_interval;
|
||||
else if(!source_missing)
|
||||
retry_after.erase(file_name);
|
||||
background_context.session.clear();
|
||||
background_context.session_loaded_hash = "";
|
||||
clear_shared_unit_cache(server_state);
|
||||
|
||||
Reference in New Issue
Block a user