mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-08-05 20:19:45 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user