From b20fdc9b9632330bb6bc189c757520a06a3f307f Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Tue, 13 Oct 2026 17:13:00 +0800 Subject: [PATCH] perf(runtime): cap tokio workers at 4 The cap of 8 was a conservative pick from 8ccb0b9a; that commit's own setup benchmark had the 4-worker / 8-blocking row as the best config: 639.3ms avg / 645.5ms max setup time and 22.1 avg threads, ahead of the adopted 8-worker row (650.1ms / 662.4ms, 26.0 threads). Startup parallelism is unaffected in practice: the setup join! polls cooperatively on one task, and CPU work (validation, script eval, YAML parse) runs on the spawn_blocking pool, which keeps its 8-thread cap through the existing 2x invariant. A 12h live session showed the 8 idle workers accumulating under 0.5s CPU total, so four parked stacks (~0.4MB dirty) are pure overhead. --- src-tauri/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 659b574b8..eb0af3195 100755 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -16,7 +16,7 @@ fn main() -> ExitCode { #[cfg(not(all(feature = "perf-harness", target_os = "macos")))] fn main() -> ExitCode { let default_parallelism = std::thread::available_parallelism().map(|n| n.get()).unwrap_or(1); - let worker_limit = std::cmp::min(default_parallelism, 8); + let worker_limit = std::cmp::min(default_parallelism, 4); let blocking_limit = 2 * worker_limit; #[allow(clippy::unwrap_used)]