crabkun / switcher

一个多功能的端口转发/端口复用工具,支持转发本地或远程地址的端口,支持正则表达式转发(实现端口复用)。
BSD 3-Clause "New" or "Revised" License
424 stars 96 forks source link

better performance by io.copy. zero copy transfer #10

Closed cppla closed 2 years ago

cppla commented 2 years ago

hi, big guy. zero copy by splice function and sendfile function,better performance for big file and more and more little file

Write and Read

- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-60.00  sec  27.5 GBytes  3.94 Gbits/sec  196             sender
[  5]   0.00-60.00  sec  27.5 GBytes  3.94 Gbits/sec                  receiver

CPU: 50%-%65%, max:80%

io.copy

- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-60.00  sec  28.0 GBytes  4.00 Gbits/sec  224             sender
[  5]   0.00-60.00  sec  27.9 GBytes  4.00 Gbits/sec                  receiver

CPU: 10%-%12%, only 10% usage
cppla commented 2 years ago

Zero Copy is a greate ways.

good luck .

crabkun commented 2 years ago

Nice PR. Thanks!!