From f676fb96de1615d3098b8cfcde09e9a82d90843d Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Tue, 11 Aug 2026 09:36:51 +0800 Subject: [PATCH] perf(wsl): stop asking twice whether a distro is ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every pane on a WSL workspace ran `ensure_wsl_server` from the client before it even connected to the daemon — and then the daemon ran the very same probe inside `router::open_link` before opening the link. Two full rounds of five serial `wsl.exe` calls, to learn one fact. The client's copy bought nothing. It threw the answer away and kept only the error, which the route ack reports just as well; and the consent question for a first install still finds its way here, because the daemon runs its probe under `RouteSetup::blocking`, which installs the relay that turns that question into a frame on this connection. Measured on a distro that was already running and connected: 800ms to open a tab, down to 440ms. Issue #454 is the same code on a machine where one `wsl.exe` round trip takes 3.3s, where the duplicate was costing 15s a tab. --- src/terminal/remote.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/terminal/remote.rs b/src/terminal/remote.rs index 51ba3362..4d01b14b 100644 --- a/src/terminal/remote.rs +++ b/src/terminal/remote.rs @@ -2105,11 +2105,18 @@ fn connect_routed(route: &PaneRoute) -> anyhow::Result { tty7_core::host::guard_off_ui(); - if let crate::daemon::router::RouteTarget::Wsl { distro } = &header.target { - crate::daemon::install::wsl::ensure_wsl_server(distro) - .map_err(|e| anyhow::anyhow!("prepare tty7-server in WSL `{distro}`: {e}"))?; - } - + // No `ensure_wsl_server` here on purpose. The daemon runs exactly the same + // probe inside `router::open_link` before it opens the link, so asking from + // this side too bought nothing and cost a second full round of `wsl.exe` + // invocations — five of them, serially, on every single pane. On a machine + // where a `wsl.exe` round trip is slow (issue #454 measured 3.3s) that + // duplicate was half of the wait before a new tab could take a key. + // + // Nothing is lost by dropping it: the returned path was discarded, the + // failure is reported just as well through the route ack below, and the + // first-install consent question still reaches this process — the daemon + // runs its probe under `RouteSetup::blocking`, which installs the relay + // that turns the question into a frame on this very connection. let mut stream = connect()?; let ack = crate::daemon::router::negotiate(&mut stream, header) .map_err(|e| anyhow::anyhow!("route this pane to {}: {e}", header.describe()))?;