perf(mpsc): increase channel capacity 32 → 1024 to reduce fallback

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.
This commit is contained in:
fanyang
2026-06-28 19:03:55 +08:00
parent 392a970db1
commit 1d80439c7c
+1 -1
View File
@@ -50,7 +50,7 @@ pub struct MpscTunnel<T> {
impl<T: Tunnel> MpscTunnel<T> {
pub fn new(tunnel: T, send_timeout: Option<Duration>) -> 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 {