xjasonlyu / tun2socks

tun2socks - powered by gVisor TCP/IP stack
https://github.com/xjasonlyu/tun2socks/wiki
GNU General Public License v3.0
2.85k stars 405 forks source link

[Bug] High CPU usage #199

Closed chromer030 closed 1 year ago

chromer030 commented 1 year ago

Verify steps

Version

latest git

What OS are you seeing the problem on?

Linux

Description

High cpu usage and new error on log :

Screenshot_20221217_201424

CLI or Config

No response

Logs

W1217 20:15:42.053644   19519 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
W1217 20:15:54.619820   19519 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
W1217 20:16:14.710499   19519 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
W1217 20:16:14.932769   19519 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected
W1217 20:16:21.858031   19519 gonet.go:457] ep.GetRemoteAddress() failed: endpoint not connected

How to Reproduce

No response

xjasonlyu commented 1 year ago

Weird, it must be a problem from the latest gVisor's commits.

chromer030 commented 1 year ago

It's more than 2 years i'm using tun2socks , and usually building from git , this is first time i encounter this errors and cpu usage.

chromer030 commented 1 year ago

Fixed in 30608f4925b7ce83bd38104b0612db6c77f1611e , Thank you !

GektorUA commented 1 year ago

For test purposes have launch (on Raspberry Pi 4B) torrents with UDP, and have very high CPU usage by tun2socks 2.4.1 version: image

And speed on UDP is around 2 MB/s, but with torrents over TCP protocol i have get almost 7 times higher speeds and much lower CPU usage.

I am understand, that torrents creates a very big numbers of connections, but anyway, is it any chance to optimize UDP stack with big number of connections?

xjasonlyu commented 1 year ago

That's not how it works. The lower UDP speed is due to the missing of congestion control algorithm.

GektorUA commented 1 year ago

So, very high CPU usage in UDP is related to the missing of congestion control algorithm?

xjasonlyu commented 1 year ago

Could be.

GektorUA commented 1 year ago

But if i am download one file over UDP, speed is much higher and CPU usage much lower.

xjasonlyu commented 1 year ago

It depends on your specific circumstance.