Repository navigation
XHTTP: bound packet-up queue allocations across concurrent uploads - #7571
Closed
wywywywycloud wants to merge 1 commit into
Closed
wywywywycloud wants to merge 1 commit into
wywywywycloud wants to merge 1 commit into
Conversation
wywywywycloud
force-pushed
the
fix/xhttp-upload-budget
branch
from
December 5, 2026 00:32
6295aa6 to
889c083
Compare
5 tasks done
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.
Related to #7568. This branch now contains only the packet-up queue change, based directly on
919d0ae. The HTTP/1.1 transport fix is in #7569 and the HTTP/2 fix is in #7572.Changes
The previous writer copied an entire Write before applying backpressure. Each stream could also fill a new queue while its previous POST was being written.
This accounts for queued buffers and the previous batch during the write. It does not cap process RSS, socket buffers or all requests awaiting responses.
Verification
OpenWrt 25.12.5 amd64 VM, two vCPUs, 256 MiB RAM, no swap,
GOMEMLIMIT=28MiB,GOGC=30. The server was unmodified Xray v26.11.9. Each round uploaded 32 MiB plus 23 bytes times the stream index per VLESS/XHTTP packet-up stream. The receiver sent back the SHA-256 of each stream. Rounds ran in one client process with five-second pauses. Memory figures are sampled RssAnon, not total system memory.Three rounds of 32 concurrent streams over TLS/HTTP/2, without an artificial RAM reservation and with a 60 MiB available-memory guard:
919d0aeThe guard stop was controlled. The standalone run completed in 50.95 seconds including pauses, without failed uploads or server queue overflows.
In a combined prototype that returned the reservation immediately on dequeue, the low-memory HTTP/2 test hit the 12 MiB guard in round three. Keeping the outgoing batch charged passed all three rounds, then the final combined build passed six rounds below.
The splithttp package passed three times. Targeted race tests passed ten times, covering tiny writes, oversized writes, shared reservations, close, interrupt and interruption with an outgoing batch. Linux arm64 cross-build passed.
Combined low-memory check
The three single-commit branches (
769b2fe,3bc0585,889c083) merged cleanly into tree80efcd74215b16ccbac413eb811f75eb90a7b53c. With 90 MiB reserved in tmpfs and a 12 MiB available-memory stop threshold, each protocol ran six rounds of 32 concurrent streams without restarting the client between rounds.A separate three-round HTTP/1.1 over TLS run passed 96/96 checks, with a 27.77 MiB peak RssAnon and 16.88 MiB minimum available. No run hit the guard, logged failed uploads or reported a server queue overflow. These are synthetic VM results. Physical ARM64 hardware was not tested.
Without the reservation the combined build passed another 192/192 HTTP/2 checks. Peak RssAnon was 27.71 MiB and minimum available memory was 78.62 MiB.
Single-stream check
For one 64 MiB HTTP/2 upload without a RAM reservation, transfer times were 3.35, 2.12 and 2.09 seconds on main and 2.25, 2.10 and 2.25 seconds with all three changes. All six digests matched. The combined median was about 6% slower in this small sample.
Codex + Astra 6.2 was used for debbugging and assisted writing the code. The chat will not be included.