perf: unblock workers before the API router is built (#10711)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-08-15 16:43:51 +02:00
committed by GitHub
parent 944ad1083a
commit 0258f3f81b
2 changed files with 14 additions and 5 deletions
+4
View File
@@ -1629,6 +1629,10 @@ Windmill Community Edition {GIT_VERSION}
}
}
// `workers_f` must stay ahead of `server_f`: these are polled on one task in
// declaration order, and `run_server` yields once after handing over the base
// internal url so the workers get past that oneshot before it builds its router.
// Ordering `server_f` first makes them wait out the whole build instead.
if mcp_mode {
futures::try_join!(workers_f, server_f)?;
} else {
+10 -5
View File
@@ -584,6 +584,16 @@ pub async fn run_server(
(Router::new(), Router::new(), Option::<()>::None)
};
// Workers block on this before pulling their first job, so it is released ahead of
// the router tree below. `try_join!` polls this future and `workers_f` on one task,
// so the yield is what lets them proceed; without it they wait out the whole
// synchronous build. A request arriving first queues in the bound listener's backlog.
if let Err(e) = port_tx.send(format!("http://localhost:{}", port)) {
tracing::error!("Failed to send port: {e:#}");
return Err(anyhow::anyhow!("Failed to send port, exiting early: {e:#}"));
}
tokio::task::yield_now().await;
let mcp_list_tools_service = {
#[cfg(feature = "mcp")]
{
@@ -1181,11 +1191,6 @@ pub async fn run_server(
name.map(|x| format!("name={x}")).unwrap_or_default()
);
if let Err(e) = port_tx.send(format!("http://localhost:{}", port)) {
tracing::error!("Failed to send port: {e:#}");
return Err(anyhow::anyhow!("Failed to send port, exiting early: {e:#}"));
}
// Announce this server is ready so coordinated restarts can detect a healthy peer.
if server_mode {
if let Err(e) = announce_server_started(&db).await {