Prewarm wasm workers before accepting requests

This commit is contained in:
udo
2026-07-16 21:00:46 +00:00
parent 83c05111a9
commit ee2177f4b4
4 changed files with 23 additions and 0 deletions
+9
View File
@@ -1388,6 +1388,15 @@ void listen_for_connections()
server.on_data = &handle_data;
server.on_complete = &handle_complete;
server.on_cli_complete = &handle_cli_complete;
Request startup_context;
startup_context.server = &server_state;
f64 wasm_start = time_precise();
String wasm_error = wasm_backend_start(startup_context);
f64 wasm_ms = (time_precise() - wasm_start) * 1000.0;
if(wasm_error == "")
printf("(P) wasm worker ready: PID %i in %.3f ms\n", getpid(), wasm_ms);
else
fprintf(stderr, "(!) wasm worker initialization failed: PID %i in %.3f ms: %s\n", getpid(), wasm_ms, wasm_error.c_str());
for(;;)
{
server.process(-1);