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

XHTTP client: Refactor "packet-up" mode, chasing "stream-up" #4150

Merged
merged 5 commits into from
Dec 11, 2024
Merged

Conversation

RPRX
Copy link
Member

@RPRX RPRX commented Dec 11, 2024

#4163 加了 hMaxRequestTimes,其实主要是利好 packet-up,也就是 H3 的默认 mode,这个 PR 同理


XHTTP packet-up 模式的上行发送大量数据会出问题,此前 #3972 (comment) 只修好了一部分,这个 PR 基于 #4100 (comment)back pressure 没到位 ...... 本来就应该等上个 POST 把数据写进系统网络栈后再弄下一个 POST”,应该是彻底修好了

比如操作系统 TCP 栈还积压着大量数据没发完,此时你又想给它塞数据,操作系统为了让你缓缓就会迟点再返回,这就是 back pressure,很好理解。而 packet-up 模式以前为了不等 response 就发下一个 POST,多个本应串行的 POST 其实是并行发出的,且并发数达到默认值 100 前无视 back pressure,这两点加起来导致了疑难杂症,比如某个 POST 迟迟没能发完,就堵塞了。

  • 这个 PR 通过 traceWroteRequest 确保了发完上一个 POST 的 body 再发下一个,且有来自 TCP/QUIC 的天然 back pressure
  • 其实这两点加起来差不多就是流式上行了,理论上和 stream-up 的表现不会有太大差距

H3 的 httptrace 尚未合并 quic-go/quic-go#4749 ,且 Xray 的依赖暂时锁在 v0.46.0,所以我 fork 了:XTLS/quic-go@571fae2 ,顺便把 traceGotConn 也加上了,此外 scMaxConcurrentPosts 改成了 scMaxBufferedPosts,仅服务端,默认值 30

最后当然是:

@RPRX

This comment was marked as outdated.

@RPRX RPRX changed the title XHTTP client: Trace WroteRequest (not supported by quic-go) in "packet-up" mode XHTTP client: Trace WroteRequest (waiting for quic-go) in "packet-up" mode Dec 11, 2024
@dragonbreath2000
Copy link
Contributor

tried this now , with setting scMaxEachPostBytes to 100000,the upload did not stuck like before with my crappy isp,great work,thanks

@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

tried this now , with setting scMaxEachPostBytes to 100000,the upload did not stuck like before with my crappy isp,great work,thanks

1000000 呢

@dragonbreath2000
Copy link
Contributor

1000000

when i set it to 1000000,it does a big burst at first but speed goes down after that a lot,my upload is extremly limited with my current isp,lowering postBytes seems to improves it for me

@RPRX

This comment was marked as outdated.

@RPRX

This comment was marked as outdated.

@dragonbreath2000
Copy link
Contributor

@dragonbreath2000You are measuring H2, right?

Yes

@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

貌似这个 PR 之后客户端就不需要 scMaxConcurrentPosts 了,完全依赖系统网络栈的 back pressure 就行

RPRX added a commit to XTLS/quic-go that referenced this pull request Dec 11, 2024
@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

干脆一步到位,于是我 fork 了 quic-go v0.46.0,加了 Xray 用到的两个 tracepoint:XTLS/quic-go@571fae2

@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

To XQZR:但凡你点开看下这个 commit XTLS/quic-go@571fae2 ,它就是从 quic-go PR 复制来的,上游合并后直接升级就行

@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

To 风扇滑翔翼:就是 POST 的 body 全被系统网络栈收了后再弄下一个,这样能保证顺序且自然有 back pressure,类似于 stream

@RPRX RPRX changed the title XHTTP client: Trace WroteRequest (waiting for quic-go) in "packet-up" mode XHTTP client: Refactor "packet-up" mode inherited from SplitHTTP Dec 11, 2024
@RPRX RPRX changed the title XHTTP client: Refactor "packet-up" mode inherited from SplitHTTP XHTTP client: Refactor "packet-up" mode, fixes upload issues Dec 11, 2024
@RPRX RPRX changed the title XHTTP client: Refactor "packet-up" mode, fixes upload issues XHTTP client: Refactor "packet-up" mode, fixes upload issues for good Dec 11, 2024
@fodhelper
Copy link

I forked quic-go v0.46.0

Isn't better to fork https://github.com/refraction-networking/uquic instead?
then you can also add fingerprint support for H3

@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

https://github.com/refraction-networking/uquic

它似乎还没有准备好

@RPRX RPRX changed the title XHTTP client: Refactor "packet-up" mode, fixes upload issues for good XHTTP client: Refactor "packet-up" mode, chasing "stream-up" Dec 11, 2024
@RPRX RPRX merged commit 8cd9a74 into main Dec 11, 2024
72 checks passed
@deepsm0ke
Copy link

Great Work!!! <3.
Update the doc whenever you can. @RPRX @Fangliding @yuhan6665
https://xtls.github.io/config/transports/splithttp.html

Hoping for more success.

@RPRX
Copy link
Member Author

RPRX commented Dec 11, 2024

其实不用更新文档了,我写那篇文章就是为了把文档整个替换掉

@RPRX RPRX deleted the wroteRequest branch December 11, 2024 15:57
@Smallthing
Copy link

是不是只有日志才能观察出握手的是H2还是H3?是3模式里面的哪一个?

@RPRX
Copy link
Member Author

RPRX commented Dec 12, 2024

是不是只有日志才能观察出握手的是H2还是H3?是3模式里面的哪一个?

Info 有输出实际使用的 mode,但我看了下上面那行 dialing splithttp to 始终是 tcp,准备改一下

RPRX added a commit that referenced this pull request Dec 12, 2024
@RPRX
Copy link
Member Author

RPRX commented Dec 12, 2024

7463561 日志加了 HTTP 版本和 host,上下行分离的下行也有日志了

zxspirit pushed a commit to zxspirit/Xray-core that referenced this pull request Dec 13, 2024
* Add wroteRequest (waiting for new quic-go)

* Use XTLS/quic-go instead

* Client doesn't need `scMaxConcurrentPosts` anymore

* GotConn is available in H3

* `scMaxConcurrentPosts` -> `scMaxBufferedPosts` (server only, 30 by default)

Fixes XTLS#4100
zxspirit pushed a commit to zxspirit/Xray-core that referenced this pull request Dec 13, 2024
@mehdifirefox
Copy link

Thank you very much for the hard work.

I haven't followed the news and information for a long time.
I don't know what progress has xray

I use more free servers
I wanted to see if I update it is good?
No need to do anything else to get better?

RPRX added a commit that referenced this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants