From e0c790eeb224f393945f880957ed975a1277cde6 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 28 Sep 2026 10:28:32 +0800 Subject: [PATCH] Tune speedtest parallelism Set `MaxDegreeOfParallelism` explicitly to the current selection size in three speed test parallel sections so task fan-out matches the workload. Also wrapped socket connect timing in a catch block that ignores connection exceptions, preventing a failed connect from aborting the flow while still completing cleanup. https://github.com/2dust/v2rayN/issues/10246 --- v2rayN/ServiceLib/Services/SpeedtestService.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index d5f10871..c1a7de38 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -210,6 +210,7 @@ public class SpeedtestService(Config config, Func updateF var parallelOptions = new ParallelOptions { + MaxDegreeOfParallelism = lst.Count, CancellationToken = ct, }; @@ -291,6 +292,7 @@ public class SpeedtestService(Config config, Func updateF var parallelOptions = new ParallelOptions { + MaxDegreeOfParallelism = selecteds.Count, CancellationToken = ct, }; @@ -381,6 +383,7 @@ public class SpeedtestService(Config config, Func updateF var parallelOptions = new ParallelOptions { + MaxDegreeOfParallelism = selecteds.Count, CancellationToken = ct, }; @@ -570,6 +573,10 @@ public class SpeedtestService(Config config, Func updateF await clientSocket.ConnectAsync(endPoint, linkedCts.Token).ConfigureAwait(false); responseTime = (int)timer.ElapsedMilliseconds; } + catch + { + // Ignore + } finally { timer.Stop();