From e66d372d05bc79fb083c9544107804a1c0fa0e55 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Thu, 26 Mar 2026 20:50:56 +0000 Subject: [PATCH] fix: force 4 tokio worker threads on node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default #[tokio::main] uses num_cpus worker threads. On small node VMs (1-2 vCPU), this gives only 1-2 worker threads. The NAT traversal poll() function does synchronous work (parking_lot locks, DashMap iteration) that blocks its worker thread. With only 1 worker, this freezes the entire runtime — timers stop, keepalives can't fire, and connections die silently. Also removes the !.cargo/config.toml exception from .gitignore so local-only patch overrides stay out of version control. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 1 - Cargo.lock | 4 +--- src/bin/ant-node/main.rs | 9 ++++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 09f42ba..09138dd 100644 --- a/.gitignore +++ b/.gitignore @@ -220,7 +220,6 @@ proptest-regressions/ # Package manager caches .cargo/ -!.cargo/config.toml # Claude/AI assistant files .claude/ diff --git a/Cargo.lock b/Cargo.lock index 8b8cc78..7f98bc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -859,7 +859,7 @@ dependencies = [ [[package]] name = "ant-node" -version = "0.6.0" +version = "0.7.0" dependencies = [ "aes-gcm-siv", "alloy", @@ -5217,8 +5217,6 @@ dependencies = [ [[package]] name = "saorsa-core" version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d3d05b97f789b0e0b7d54b2fe05f05edfafb94f72d065482fc20ce1e9fab69e" dependencies = [ "anyhow", "async-trait", diff --git a/src/bin/ant-node/main.rs b/src/bin/ant-node/main.rs index c3f557d..390798b 100644 --- a/src/bin/ant-node/main.rs +++ b/src/bin/ant-node/main.rs @@ -10,7 +10,14 @@ use tracing::{info, warn}; use tracing_subscriber::prelude::*; use tracing_subscriber::{fmt, EnvFilter, Layer}; -#[tokio::main] +/// Force at least 4 worker threads regardless of CPU count. +/// +/// On small VMs (1-2 vCPU), the default `num_cpus` gives only 1-2 worker +/// threads. The NAT traversal `poll()` function does synchronous work +/// (`parking_lot` locks, `DashMap` iteration) that blocks its worker thread. +/// With only 1 worker, this freezes the entire runtime — timers stop, +/// keepalives can't fire, and connections die silently. +#[tokio::main(flavor = "multi_thread", worker_threads = 4)] async fn main() -> color_eyre::Result<()> { // Initialize error handling color_eyre::install()?;