From 1d80439c7cb87cfbbe8918ef89d81fe8d2b08d00 Mon Sep 17 00:00:00 2001 From: fanyang Date: Sun, 28 Jun 2026 19:03:55 +0800 Subject: [PATCH] =?UTF-8?q?perf(mpsc):=20increase=20channel=20capacity=203?= =?UTF-8?q?2=20=E2=86=92=201024=20to=20reduce=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit channel(32) was frequently full under high pps, causing try_send to fail and fall back to send().await (semaphore wait). Increasing to 1024 reduces fallback frequency. Benchmark (4 threads, 1400B, 15s): MpscTunnelSender::send avg: 2.23us → 2.01us (-220ns) MpscTunnelSender::send P95: 6.39us → 5.74us (-650ns) send_msg_internal avg: 2.67us → 2.45us (-220ns) pps: ~250K (unchanged, receiver-bound) pps unchanged because bottleneck moved to receiver (forward_one_round → sink.feed/flush). The 220ns/pkt saving is pure CPU efficiency gain. --- easytier/src/tunnel/mpsc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easytier/src/tunnel/mpsc.rs b/easytier/src/tunnel/mpsc.rs index e131d66b..7e7d51ef 100644 --- a/easytier/src/tunnel/mpsc.rs +++ b/easytier/src/tunnel/mpsc.rs @@ -50,7 +50,7 @@ pub struct MpscTunnel { impl MpscTunnel { pub fn new(tunnel: T, send_timeout: Option) -> Self { - let (tx, mut rx) = hotpath::channel!(channel(32)); + let (tx, mut rx) = hotpath::channel!(channel(1024)); let (stream, mut sink) = tunnel.split(); let task = tokio::spawn(async move {