Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] TCP Fast Open #184

Closed
2 of 5 tasks
zonyitoo opened this issue Dec 31, 2019 · 14 comments · Fixed by #487
Closed
2 of 5 tasks

[FEATURE] TCP Fast Open #184

zonyitoo opened this issue Dec 31, 2019 · 14 comments · Fixed by #487
Assignees

Comments

@zonyitoo
Copy link
Collaborator

zonyitoo commented Dec 31, 2019

TCP Fast Open is supported in shadowsocks-libev. Since it is one of the most popular shadowsocks servers implementation, it would better to be compatible with it.

TODO

@zonyitoo zonyitoo self-assigned this Dec 31, 2019
@zonyitoo
Copy link
Collaborator Author

Since Mio and Tokio don't have plan on supporting TFO, I am going to write a separate crate (mio-tfo, tokio-tfo maybe).

zonyitoo added a commit that referenced this issue Jan 1, 2020
Removed `trust-dns` feature gate, uses trust-dns-resolver as default
zonyitoo added a commit that referenced this issue Jan 2, 2020
TFO on macOS (seems) the second send call must wait until the first recv
has called. Don't know why.
@dev4u
Copy link

dev4u commented May 9, 2020

Why spend time on tfo?
As far as my experience in use, there is no perceptible improvement to the use effect.
It will also cause instability under the mobile network.

@zonyitoo
Copy link
Collaborator Author

zonyitoo commented May 9, 2020

Yup. So I have given up.

@0x112
Copy link

0x112 commented Apr 7, 2021

@zonyitoo 请问这个特性有进展吗?

Why spend time on tfo?
As far as my experience in use, there is no perceptible improvement to the use effect.
It will also cause instability under the mobile network.

我觉得还是作为一个可选项加进来比较好,因为有时候不需要用到移动网络。
当我在使用libev版本的时候,两端开启TFO时并成功生效时,会感觉快一点点,可以用这些命令可以测试TFO是否开启:

grep '^TcpExt:' /proc/net/netstat | cut -d ' ' -f 91-96 | column -t
grep '^TcpExt:' /proc/net/netstat | cut -d ' ' -f 90-95 | column -t

@database64128
Copy link
Contributor

TFO is dead. This issue should be closed.

@zonyitoo
Copy link
Collaborator Author

zonyitoo commented Apr 7, 2021

@zonyitoo 请问这个特性有进展吗?

Nope. I haven't spent any time on it recently. But I have already done in my local branch.

TFO requires lots of changes in API and haven't supported officially by mainstream network libraries in Rust, such as libstd, async-std, tokio, mio. It is quite nasty to make the current API to be compatible with TFO.

IMHO, TFO is dead. I don't see any massive production use case with TFO, maybe because TFO have to be supported by the OS, and it requires applications to support it explicitly by calling different APIs.

Back to this issue, I won't doubt that TFO may have benefits on connection latency, but it shouldn't be a lot that you can "feel" without having pressure tests. The performance test in this paper shows the following conclution:

As expected, TFO improves the PLT when the RTT is high for all the sites we tested. When the RTT is small and the network delay is only a small fraction of PLT, the resource processing time would exceed network time, so the gains from TFO are expected to be small. But even for pages heavy on content and with short emulated RTT (i.e. 20ms), TFO accelerates PLT by 4–5%. Conversely, for simpler pages such as wikipedia, the browser spends most of its time waiting for network transfers rather than processing the retrieved content, and thus TFO offers significant improvements of 16% and 41% with 100ms and 200ms RTTs respectively. The 200ms RTT figures roughly correspond to the expected performance on mobile devices since mobile RTTs are typically on the order of 100–200ms

So it should benefit in high RTT networks, and the network between locals and servers are usually have high RTTs. In other words, TFO may have benefits in this project.

But I would prefer using v2ray-plugin with quic enabled. :)

On the other hand, in this article, https://squeeze.isobar.com/2019/04/11/the-sad-story-of-tcp-fast-open/ ,

Over the years, Google and Mozilla did more testing and eventually found that TFO wasn’t beneficial. Clients that initiate TFO connections encounter failures requiring them to re-try without TFO so often that, on average, TFO costs more time than it saves. In some networks, TFO never works – for example, China Mobile’s firewall consistently fails to accept TFO requiring every connection to be retried without it, leading to TFO actually increasing roundtrips.

@0x112
Copy link

0x112 commented Apr 7, 2021

So it should benefit in high RTT networks, and the network between locals and servers are usually have high RTTs. In other words, TFO may have benefits in this project.

我大概清楚了,十分感谢您的解答 :)

@zonyitoo
Copy link
Collaborator Author

zonyitoo commented Apr 7, 2021

Any PRs are welcome. But consider the downside of TFO, I don't think it is urgent.

@zonyitoo
Copy link
Collaborator Author

zonyitoo commented Apr 8, 2021

After a day, I am getting interested in pushing this forward. No matter it is useful or not, just for fun.

@0x112
Copy link

0x112 commented Apr 8, 2021

After a day, I am getting interested in pushing this forward. No matter it is useful or not, just for fun.

😅😅作为一个Optional Features怎么样?如果需要用到才在编译时加入--features "tcp-fast-open"会不会比较好?

(另外想请教一下,ss-rust的二进制文件比较大,能不能在编译时执行strip?我现在用了这个方法:rust-lang/cargo#3483 (comment) 这是正确的做法吗?)

@zonyitoo
Copy link
Collaborator Author

zonyitoo commented Apr 8, 2021

#276

It is 2021 now, what kind of device couldn't provide 2MB free space?

@0x112
Copy link

0x112 commented Apr 8, 2021

#276

谢谢 👍

It is 2021 now, what kind of device couldn't provide 2MB free space?

这不是空间的问题,只是想习惯性的削减一下体积

@zonyitoo
Copy link
Collaborator Author

zonyitoo commented Apr 8, 2021

Compile with -s will make generated code to be a lot slower.

@0x112
Copy link

0x112 commented Apr 8, 2021

Compile with -s will make generated code to be a lot slower.

感谢提醒哈,我原本是以为对性能无影响才想要strip的。。。

zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 9, 2021
zonyitoo added a commit that referenced this issue Apr 10, 2021
zonyitoo added a commit that referenced this issue Apr 10, 2021
zonyitoo added a commit that referenced this issue Apr 10, 2021
zonyitoo added a commit that referenced this issue Apr 11, 2021
zonyitoo added a commit that referenced this issue Apr 11, 2021
zonyitoo added a commit that referenced this issue Apr 11, 2021
zonyitoo added a commit that referenced this issue Apr 11, 2021
zonyitoo added a commit that referenced this issue Apr 15, 2021
zonyitoo added a commit that referenced this issue Apr 15, 2021
atkdef pushed a commit to atkdef/shadowsocks-rust that referenced this issue Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants