Avoid duplicate proactive recompilation

This commit is contained in:
udo
2026-07-18 22:23:44 +00:00
parent 33a7b00c78
commit 14f4920ae8
3 changed files with 53 additions and 13 deletions
+7 -4
View File
@@ -1245,14 +1245,14 @@ void proactive_compile_queue_push(StringList& queue, String file_name)
queue.push_back(file_name);
}
bool proactive_compile_unit(Request& context, String file_name, bool& source_missing, bool force_compile = false)
bool proactive_compile_unit(Request& context, String file_name, bool& source_missing, bool retry_current_failure = false)
{
bool failed = false;
String wasm_path = compiler_unit_wasm_path(&context, file_name);
if(force_compile || compiler_unit_needs_recompile(&context, file_name, &source_missing))
if(retry_current_failure || compiler_unit_needs_recompile(&context, file_name, &source_missing))
{
printf("(i) proactive compile %s\n", file_name.c_str());
auto su = force_compile ? compiler_get_shared_unit_internal(&context, file_name, true) : get_shared_unit(&context, file_name);
auto su = retry_current_failure ? compiler_get_shared_unit_internal(&context, file_name, false, true) : get_shared_unit(&context, file_name);
failed = !su || su->compiler_messages != "";
if(su)
wasm_path = su->wasm_name;
@@ -1383,7 +1383,10 @@ void run_proactive_compiler(u64 worker, u64 jobs)
if(retry_it != retry_after.end() && time_precise() < retry_it->second)
continue;
bool normal_compile = compiler_unit_needs_recompile(&background_context, file_name, &source_missing);
bool failed = proactive_compile_unit(background_context, file_name, source_missing, !normal_compile && !source_missing);
bool retry_due = retry_it != retry_after.end();
bool retry_current_failure = retry_due && !normal_compile && !source_missing &&
compiler_unit_needs_recompile(&background_context, file_name, 0, false, true, true);
bool failed = proactive_compile_unit(background_context, file_name, source_missing, retry_current_failure);
if(source_missing)
retry_after.erase(file_name);
else if(failed)