clowwindy / ShadowVPN

Removed according to regulations.
1.47k stars 1.06k forks source link

Reduce CPU time by half #93

Closed clowwindy closed 9 years ago

lsylsy2 commented 9 years ago

两台机器 分别为Atom D525与Core 2 Duo E4400,在同一个百兆交换机下,直接互联iperf 94.6Mbps,透过shadowvpn为90.7Mbps,瓶颈均为百兆网口(vnstat显示网卡带宽均为96.15Mbps),shadowvpn最高CPU占用为D525一个核心的92.5%。

lsylsy2 commented 9 years ago

使用iperf -d双向同时测试时,D525的CPU达到极限(单核)。 一下数据均为D525一侧,双向测试时D525发送至E4400方向的带宽要高一些。 VPN

phiyme@atom1717:~$ iperf -c 10.9.0.2 -d
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 10.9.0.2, TCP port 5001
TCP window size: 69.3 KByte (default)
------------------------------------------------------------
[  5] local 10.9.0.1 port 55413 connected with 10.9.0.2 port 5001
[  4] local 10.9.0.1 port 5001 connected with 10.9.0.2 port 40000
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-10.0 sec  98.8 MBytes  82.7 Mbits/sec
[  4]  0.0-10.1 sec  33.5 MBytes  27.9 Mbits/sec

直连

phiyme@atom1717:~$ iperf -c 192.168.1.6 -d
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 192.168.1.6, TCP port 5001
TCP window size: 67.1 KByte (default)
------------------------------------------------------------
[  5] local 192.168.1.5 port 33927 connected with 192.168.1.6 port 5001
[  4] local 192.168.1.5 port 5001 connected with 192.168.1.6 port 60163
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-10.0 sec   110 MBytes  92.3 Mbits/sec
[  4]  0.0-10.1 sec  87.2 MBytes  72.6 Mbits/sec

将窗口扩大至256K,总带宽无明显区别,直连无明显区别,经过VPN的两个方向带宽平均了一些。

phiyme@atom1717:~$ iperf -c 10.9.0.2 -d -w 256K
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size:  256 KByte (WARNING: requested  256 KByte)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 10.9.0.2, TCP port 5001
TCP window size:  256 KByte (WARNING: requested  256 KByte)
------------------------------------------------------------
[  5] local 10.9.0.1 port 55418 connected with 10.9.0.2 port 5001
[  4] local 10.9.0.1 port 5001 connected with 10.9.0.2 port 40004
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-10.0 sec  74.1 MBytes  62.0 Mbits/sec
[  4]  0.0-10.0 sec  56.9 MBytes  47.5 Mbits/sec
lsylsy2 commented 9 years ago

D525单核性能供参考:

phiyme@atom1717:~$ openssl speed md5 Doing md5 for 3s on 16 size blocks: 1362644 md5's in 3.00s Doing md5 for 3s on 64 size blocks: 1478355 md5's in 2.99s Doing md5 for 3s on 256 size blocks: 1120104 md5's in 3.00s Doing md5 for 3s on 1024 size blocks: 573234 md5's in 3.00s Doing md5 for 3s on 8192 size blocks: 103226 md5's in 3.00s OpenSSL 1.0.1e 11 Feb 2013 built on: Wed Oct 15 18:23:58 UTC 2014 options:bn(64,32) rc4(8x,mmx) des(ptr,risc1,16,long) aes(partial) blowfish(idx) compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DL FCN -DHAVE_DLFCN_H -DL_ENDIAN -DTERMIO -g -O2 -fstack-protector --param=ssp-buff er-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wa, --noexecstack -Wall -march=i686 -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes md5 7267.43k 31643.72k 95582.21k 195663.87k 281875.80k