shadowsocks / shadowsocks-libev

Bug-fix-only libev port of shadowsocks. Future development moved to shadowsocks-rust
https://github.com/shadowsocks/shadowsocks-rust
GNU General Public License v3.0
15.83k stars 5.69k forks source link

50% less single thread throughput on openwrt/LEDE router with smaller RAM size #1755

Closed moralrebuild closed 7 years ago

moralrebuild commented 7 years ago

What version of shadowsocks-libev are you using?

3.1.0

What operating system are you using?

LEDE 17.01.4 or Openwrt 15.05.1 on well-known wireless router TP-Link WR703N

What did you do?

benchmark the maximal throughput with youtube-dl

What did you expect to see?

Can achieve comparable throughput on the same router with 32MB RAM or above.

What did you see instead?

with single youtube-dl thread on client, router was throttled at: 1.2MB/second on MOD TP-Link WR703N with 8MB flash and 64MB RAM @50% CPU usage 700KB/second on stock TP-Link WR703N with 4MB flash and 32MB RAM @30% CPU usage Both CPU and memory has solid available resource under the stress test.

In fact, the MOD router only needs 2 download sessions to saturate the CPU with 2000KB/second the stock router needs 3 download sessions to saturate the CPU with 2000KB/second

The pain point is that current shadowsocks-libev's unfriendliness to smaller memory implementation prevents end user device from smoothly streaming HD video over stock router.

What is your config in detail (with all sensitive info masked)?

shadowsocks.json:

{ "server": "11.22.33.44", "server_port": 12345, "password": "secret", "method": "chacha20-ietf-poly1305", "local_address": "0.0.0.0", "timeout": 60, "reuse_port": true }

madeye commented 7 years ago

32MB RAM is too mall for chacha20-ietf-poly1305.

Try rc4-md5 if your router is a really low-end router.

moralrebuild commented 7 years ago

@madeye 'rc4-md5' is vulnerable and very unstable on my ISP. It's not a good choice. On the other hand, there are very few options in the area of portable wireless router.

moralrebuild commented 7 years ago

@madeye So we already did some study about the memory footprint for the "chacha20-ietf-poly1305", the new and recommended AEAD encryption method?

greenbambooaaron commented 7 years ago

The Xiaomi Mini router is only 120rmb on taobao and I see peak rates of 10mbps with chacha20. It might be time for you to buy a better router... (The Xiaomi 3G is also supported by snapshot builds of LEDE, costs about 220-250rmb on taobao, and I see peak rates around 20mpbs with the chacha20 cipher)

moralrebuild commented 7 years ago

@greenbambooaaron Thanks, but if your number is accurate , I couldn't see much advantage from your mentioned router mode. The TP-link wr703n can achieve 2000KB/ = 2000Kb/s*8 =16000kbps = 16000/1024 mbps = 16mbps

greenbambooaaron commented 7 years ago

@moralrebuild I've used that same TP Link router extensively in the past, and it's a good little router. I tried to use it with OpenVPN+STUNNEL but ended up switching to D-Link for a larger ROM that supports more packages. I had to buy those 2-hand through through taoabo and I wanted something new that I could recommend to friends. The Xiaomi is my favorite now since they're spec'd well and their commercial ROM is already based on OpenWRT.

I'm a hobbyist, and a new one at that with Shadowsocks, so I might be missing the point of your issue. However the issue at hand that I was addressing, per @madeye's comments, is the RAM in your router and not the processor.

Also, I'm not sure how you calculate your router's performance, I was just talking about my observed speeds. It seems that spec-per-spec, the Xiaomi will out-perform the TP-Link handily:

TP-Link WR703N=Atheros AR9331 @400MHz, 4MB Flash, 32MB RAM Full Specs, TP-Link

Xiaomi Mini=MediaTek MT7620A @580MHz, 16MB ROM, 128MB RAM Full Specs, Xiaomi Mini

moralrebuild commented 7 years ago

@greenbambooaaron Just like you I am also a hobbyist. I want to solve the network censorship at different scenarios with its own best solutions. At home, with over 100mbps ISP bandwidth, I usually rely on either the most powerful NUC sized x64/debian as backbone router or Netgear R7800 (1.7GHz dual ARM cores)/LEDE to replace the years old ASUS AC68U/Netgear R7000 Merlin. When on trip, I prefer to take a true mini (Xiaomi's mini naming is a joke) portable WIFI router like WR703N. I know there are some alternatives for the latter. In fact, I already tried two kinds of MT7260 routers: one is GL-iNet MT300N another Nexx WT3020F. Only TP-Link's WR703N doesn't need to perform manually reboot after 24-hour heavy duty. I don't know who should be blamed, MediaTek's inferior cooling or LEDE's poor code quality support of the chip.

madeye commented 7 years ago

'rc4-md5' is vulnerable and very unstable on my ISP. It's not a good choice. On the other hand, there are very few options in the area of portable wireless router.

I don't think so. You may also try simple-obfs with shadowsocks-libev to improve the "unstable" connections.