mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-07 18:57:14 +00:00
6436fd9c5c
stackTun's incomingPacket channel (the handoff from gVisor's internal sender to amneziawg-go's TUN-reading/encrypt/UDP-send goroutine) was unbuffered. WriteNotify pushes into it synchronously from whatever gVisor goroutine is sending TCP data, so every single outbound (download/server->client) packet forced a full blocking round trip between gVisor and the single RoutineReadFromTUN goroutine, one packet at a time with no pipelining. The upload/client->server direction has no equivalent stall: Write -> InjectInbound -> DeliverNetworkPacket hands off into gVisor's own ~1MB per-connection TCP receive buffer and returns immediately. That asymmetry -- not a tunable window size -- is what produced observed download throughput far below upload on a real test connection. Give incomingPacket the same queue depth as the channel endpoint's own outbound queue (1024) so gVisor can get meaningfully ahead of the encrypt/send loop instead of blocking on every packet.