Stage ABI-scoped unit generations
This commit is contained in:
+33
-1
@@ -1221,7 +1221,7 @@ void proactive_compile_queue_push(StringList& queue, String file_name)
|
||||
bool proactive_compile_unit(Request& context, String file_name, bool& source_missing)
|
||||
{
|
||||
bool failed = false;
|
||||
String wasm_path = server_state.config["BIN_DIRECTORY"] + file_name + ".wasm";
|
||||
String wasm_path = compiler_unit_wasm_path(&context, file_name);
|
||||
if(compiler_unit_needs_recompile(&context, file_name, &source_missing))
|
||||
{
|
||||
printf("(i) proactive compile %s\n", file_name.c_str());
|
||||
@@ -1582,6 +1582,36 @@ void init_base_process()
|
||||
srand(time());
|
||||
}
|
||||
|
||||
int precompile_unit_generation()
|
||||
{
|
||||
f64 started_at = time_precise();
|
||||
server_state.config = make_server_settings();
|
||||
server_state.config["COMPILER_SYS_PATH"] = cwd_get();
|
||||
Request background_context;
|
||||
background_context.server = &server_state;
|
||||
mkdir(server_state.config["BIN_DIRECTORY"]);
|
||||
mkdir(compiler_unit_bin_directory(&background_context));
|
||||
|
||||
set_active_request(background_context);
|
||||
auto files = compiler_scan_site_units(&background_context);
|
||||
compiler_set_known_units(&background_context, files);
|
||||
u64 failed = 0;
|
||||
u64 compiled = 0;
|
||||
for(auto& file_name : files)
|
||||
{
|
||||
bool source_missing = false;
|
||||
if(compiler_unit_needs_recompile(&background_context, file_name, &source_missing))
|
||||
compiled++;
|
||||
if(proactive_compile_unit(background_context, file_name, source_missing))
|
||||
failed++;
|
||||
}
|
||||
printf("Precompiled unit generation %s: %zu units, %llu compiled, %llu failed in %.3f s\n",
|
||||
compiler_unit_bin_directory(&background_context).c_str(), files.size(),
|
||||
(unsigned long long)compiled, (unsigned long long)failed,
|
||||
time_precise() - started_at);
|
||||
return(failed == 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// systemd connects stdout to a pipe, which otherwise block-buffers child
|
||||
@@ -1592,6 +1622,8 @@ int main(int argc, char** argv)
|
||||
// after a fault does not allocate.
|
||||
backtrace(request_fault_frames, 4);
|
||||
process_start_directory();
|
||||
if(argc == 2 && String(argv[1]) == "--precompile")
|
||||
return(precompile_unit_generation());
|
||||
|
||||
init_base_process();
|
||||
ensure_proactive_compiler();
|
||||
|
||||
Reference in New Issue
Block a user