Repository navigation
XHTTP server: Advertise 16 KiB HTTP/2 max frame size - #7099
Closed
denissilantev64 wants to merge 1 commit into
Closed
denissilantev64 wants to merge 1 commit into
denissilantev64 wants to merge 1 commit into
Conversation
Member
|
迟迟没有加的原因是硬编码一个额外的值可能导致特征 对于经过转发器(如CDN)的节点又很可能不受控 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go's HTTP/2 client (
golang.org/x/net/http2) gives every stream a request body buffer ofmin(server's SETTINGS_MAX_FRAME_SIZE, 512 KiB)and keeps it for as long as it writes the body (frameScratchBufferLen/writeRequestBody). An XHTTP stream-one or stream-up request body lasts as long as the proxied connection. Go's server advertises 1 MiB, so on the client every open XHTTP stream pins 512 KiB.A client with many connections at once pays that per connection — a browser opening a heavy page, for example. On iOS the packet tunnel provider is limited to 50 MB (#4422), and this buffer alone takes the limit.
This change makes the XHTTP server advertise 16 KiB, the protocol's initial value (RFC 9113, 6.5.2). Each stream's buffer becomes 16 KiB. It only limits frames from client to server; downloads are unaffected. Clients need no update: the protocol requires them to respect
SETTINGS_MAX_FRAME_SIZE, and 16 KiB is the value they use until the server's first SETTINGS arrives.Measurements
Setup: VLESS + XHTTP stream-one + REALITY. Server on Linux with 100 ms of
netemdelay, stock Xray client, the same build with and without this change.The same buffer was the largest single holder on an Android client (hev-socks5-tunnel in front of Xray): 70–120 MB in heap profiles with 32–64 workers of short requests.
Test
Test_ListenXH_HTTP2MaxFrameSizereads the server's first SETTINGS frame. It fails onmain(1048576) and passes with this change.Not in this PR
The other large per-stream item on the client is the HTTP/2 receive window. The XHTTP h2 transport sets none, so
x/netdefaults apply: 4 MiB per stream and 1 GiB per connection. With slow readers, every stream can hold up to 4 MiB.Unlike this change, lowering the window costs throughput. At 100 ms RTT one stream does about window / RTT:
So it would have to be opt-in, much like the window settings in
quicParamsfor HTTP/3. We can send that as a separate PR if you tell us which config shape you prefer.