go-gost / gost

GO Simple Tunnel - a simple tunnel written in golang
https://gost.run
MIT License
4.02k stars 496 forks source link

[Feature Request] splice() support (improves performance). #490

Open przemyslaw0 opened 3 months ago

przemyslaw0 commented 3 months ago

It is already implemented in Go standard library: https://github.com/golang/go/blob/master/src/net/splice_linux.go#L12-L49

It is TCP/Linux only, but for improving performance of UDP, recvmmsg() and sendmmsg() can be implemented in gost too.

recvmmsg() and sendmmsg() for UDP it already implemented in this project: https://github.com/search?q=repo%3Adatabase64128%2Fshadowsocks-go%20recvmmsg&type=code

Thanks.

przemyslaw0 commented 1 month ago

I made some tests for SOCKS5 performance between GOST and Glider (Intel Core i3-7100):

GOST:

$ proxychains4 iperf3 -c 127.0.0.1
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] Strict chain  ...  127.0.0.1:1111  ...  127.0.0.1:5201  ...  OK
Connecting to host 127.0.0.1, port 5201
[proxychains] Strict chain  ...  127.0.0.1:1111  ...  127.0.0.1:5201  ...  OK
[  9] local 127.0.0.1 port 50500 connected to 127.0.0.1 port 1111
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  9]   0.00-1.00   sec  1.77 GBytes  15.2 Gbits/sec    1    639 KBytes       
[  9]   1.00-2.00   sec  1.75 GBytes  15.0 Gbits/sec    1    512 KBytes       
[  9]   2.00-3.00   sec  1.71 GBytes  14.7 Gbits/sec    2    639 KBytes       
[  9]   3.00-4.00   sec  1.69 GBytes  14.5 Gbits/sec    1    639 KBytes       
[  9]   4.00-5.00   sec  1.68 GBytes  14.5 Gbits/sec    0    639 KBytes       
[  9]   5.00-6.00   sec  1.76 GBytes  15.1 Gbits/sec    0    639 KBytes       
[  9]   6.00-7.00   sec  1.64 GBytes  14.1 Gbits/sec    0    895 KBytes       
[  9]   7.00-8.00   sec  1.75 GBytes  15.0 Gbits/sec    0    576 KBytes       
[  9]   8.00-9.00   sec  1.57 GBytes  13.5 Gbits/sec    0    767 KBytes       
[  9]   9.00-10.00  sec  1.31 GBytes  11.2 Gbits/sec    2    512 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  9]   0.00-10.00  sec  16.6 GBytes  14.3 Gbits/sec    7             sender
[  9]   0.00-10.00  sec  16.6 GBytes  14.3 Gbits/sec                  receiver

iperf Done.

Glider:


$ proxychains4 iperf3 -c 127.0.0.1
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] Strict chain  ...  127.0.0.1:1111  ...  127.0.0.1:5201  ...  OK
Connecting to host 127.0.0.1, port 5201
[proxychains] Strict chain  ...  127.0.0.1:1111  ...  127.0.0.1:5201  ...  OK
[  9] local 127.0.0.1 port 57258 connected to 127.0.0.1 port 1111
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  9]   0.00-1.00   sec  3.52 GBytes  30.2 Gbits/sec    1    384 KBytes       
[  9]   1.00-2.00   sec  3.56 GBytes  30.5 Gbits/sec    0    512 KBytes       
[  9]   2.00-3.00   sec  3.54 GBytes  30.4 Gbits/sec    2    512 KBytes       
[  9]   3.00-4.00   sec  3.53 GBytes  30.4 Gbits/sec    1    512 KBytes       
[  9]   4.00-5.00   sec  3.58 GBytes  30.7 Gbits/sec    0    512 KBytes       
[  9]   5.00-6.00   sec  3.53 GBytes  30.3 Gbits/sec    2    512 KBytes       
[  9]   6.00-7.00   sec  3.54 GBytes  30.4 Gbits/sec    1    384 KBytes       
[  9]   7.00-8.00   sec  3.52 GBytes  30.2 Gbits/sec    4    512 KBytes       
[  9]   8.00-9.00   sec  3.24 GBytes  27.8 Gbits/sec    0    512 KBytes       
[  9]   9.00-10.00  sec  2.54 GBytes  21.8 Gbits/sec    1    831 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  9]   0.00-10.00  sec  34.1 GBytes  29.3 Gbits/sec   12             sender
[  9]   0.00-10.00  sec  34.1 GBytes  29.3 Gbits/sec                  receiver

iperf Done.

splice() support almost doubles the data rate transmission, here is good reason to implement it.