Skip to content

XDRIVE: when the client disappears mid-download, the server uploads the rest of the response and keeps the session for minutes #7208

Open

Description

@4erdenko

Integrity requirements

  • I have read all the comments in the issue template and ensured that this issue meet the requirements.
  • I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
  • I searched issues and did not find any similar issues.
  • The problem can be successfully reproduced in the latest Release

Description

简述:在 v26.10.17(与 main 相同)中,如果 XDRIVE 客户端在下载中途消失(进程被杀或断网),服务端无法察觉:它会继续从目标读取,并把剩余的整个响应写入存储(复现中 20 秒内写入约 235 MiB、607 个对象)。这些对象要等服务端的 mux 子连接自行结束后才会被清理(约 2.7–13 分钟),期间该会话仍被持续 LIST 轮询。原因是 XDRIVE 既没有对端存活检测,也没有背压。

Version: v26.10.17 (92ccc93, the newest release and the same commit as current main), network: "xdrive", service: "local". XDRIVE is only in the pre-releases since v26.9.30; it is not in v26.3.27. The session logic involved does not depend on the backend, so remote backends behave the same way.

When an XDRIVE client disappears in the middle of a download (process killed, network lost, which is common for mobile clients), the server does not notice:

  1. It keeps reading from the target and writes the whole remaining response into the storage. In the repro the client had received 22 MiB of a 256 MiB body; within 20 s after the client was killed the server wrote 246,869,084 bytes in 607 objects.
  2. These objects stay until the server-side mux sub-connection ends on its own: about 2.7 min when the target closes the connection after the body, about 13 min with a keep-alive target. Meanwhile the dead session is still polled (about 2 LIST per second).
  3. The server logs nothing after the client is gone, even at debug.

With a remote backend every abandoned download can upload hundreds of MiB into the storage account, consume API quota and leave the objects there for minutes.

If only the application connection is closed while the client stays alive (curl killed), the server stops writing within about 5 s and the folder is cleaned up, so the problem is specific to the peer disappearing.

256 MiB body at 16 MiB/s, sessionTtlSeconds: 30 storage at +30 s +90 s +180 s server kept writing
download completes (control) 0 B 0 B 0 B no
client kill -9 after ~2 s 246,869,084 B / 607 objects same same yes, the whole remaining body
client SIGTERM after ~2 s 246,394,446 B / 515 objects same same yes
curl killed, client alive 0 B (one .end) 0 B 0 B no, stopped within ~5 s
client kill -9, keep-alive target, watched 900 s 246,453,796 B same same yes; empty only at ~750–780 s
client kill -9, target sends Connection: close 246,485,923 B same 0 B yes; empty at ~165 s

Cause

  • Listener.claim marks the session active (transport/internet/xdrive/xdrive.go:225); the mark is removed only in the connection's onClose (xdrive.go:234). collect() skips active sessions (xdrive.go:267-269), so the folder of a dead session is not collected while the server-side connection is open.
  • That connection is closed only when the inbound handler returns (app/proxyman/inbound/worker.go:123-127), i.e. after the server-side mux session ends. XDRIVE has no peer liveness signal: no heartbeat, no idle timeout. Conn.receive blocks on the reader channel (conn.go:53-61), walReader.poll returns quietly on an empty listing (wal.go:295-297), holeTimeout fires only when later segments exist (wal.go:312-321), EOF comes only from a .end object (wal.go:365).
  • No backpressure: walWriter.Write appends to the buffer and flushLocked starts go w.upload (wal.go:73-91, wal.go:127-156); the semaphore in upload limits concurrent Puts, not unconsumed data (wal.go:161-166). Segments are deleted only by the peer's reader, so nothing limits what is written for a reader that is gone.

A scratch build with extra logging showed collect() skipping the session on every pass, and the server connection closing only after the mux worker finished.

Possible fix

  • Limit unconsumed data per direction: the reader already deletes consumed segments, so the writer can stop flushing while more than N of its own segments are still listed (or the reader publishes an ack object).
  • Or a peer liveness signal: a small heartbeat object refreshed by each side while the session is open; close the connection and release active when the peer's heartbeat is older than an idle timeout.

Reproduction Method

  1. Create an empty folder /tmp/xdrive-store. The configs below use throwaway keys from xray vlessenc.
  2. python3 target.py 18080 16 & — a local target serving a 256 MiB body at 16 MiB/s (script below).
  3. xray run -c server.json &, then xray run -c client.json &.
  4. curl -sS --socks5-hostname 127.0.0.1:21005 -o /dev/null http://127.0.0.1:18080/body &
  5. After about 2 s: kill -9 <client xray pid>.
  6. Every 10 s: du -sk /tmp/xdrive-store; find /tmp/xdrive-store -type f | wc -l. The folder grows to about 235 MiB within 20 s and stays there for minutes.
target.py
#!/usr/bin/env python3
# GET /body serves a 256 MiB body at a capped rate. Usage: target.py PORT MIB_PER_S [close]
import sys
import time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

PORT = int(sys.argv[1])
RATE_MIB = float(sys.argv[2]) if len(sys.argv) > 2 else 16.0
CLOSE = len(sys.argv) > 3 and sys.argv[3] == "close"
MIB = 1024 * 1024
TOTAL = 256 * MIB
CHUNK = b"x" * (256 * 1024)

class Handler(BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1"

def log_message(self, *args):
    pass

def do_GET(self):
    self.send_response(200)
    self.send_header("Content-Length", str(TOTAL))
    if CLOSE:
        self.send_header("Connection", "close")
        self.close_connection = True
    self.end_headers()
    pause = len(CHUNK) / (RATE_MIB * MIB)
    try:
        for _ in range(TOTAL // len(CHUNK)):
            self.wfile.write(CHUNK)
            time.sleep(pause)
    except OSError:
        pass

class Server(ThreadingHTTPServer):
daemon_threads = True

Server(("127.0.0.1", PORT), Handler).serve_forever()

Client config

Details
{
  "log": {
    "loglevel": "debug",
    "dnsLog": true
  },
  "inbounds": [
    {
      "tag": "socks",
      "listen": "127.0.0.1",
      "port": 21005,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "127.0.0.1",
            "port": 22005,
            "users": [
              {
                "id": "11111111-2222-4333-8444-555555555555",
                "encryption": "mlkem768x25519plus.native.0rtt.rBBIc7U3hDYCJmmA2eEZ61T_iqorCP_JTlHSQdPp8iA"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "xdrive",
        "xdriveSettings": {
          "service": "local",
          "remoteFolder": "/tmp/xdrive-store",
          "sessionTtlSeconds": 30
        }
      },
      "mux": {
        "enabled": true
      }
    }
  ]
}

Server config

Details
{
  "log": {
    "loglevel": "debug",
    "dnsLog": true
  },
  "inbounds": [
    {
      "tag": "in",
      "listen": "127.0.0.1",
      "port": 22005,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "11111111-2222-4333-8444-555555555555"
          }
        ],
        "decryption": "mlkem768x25519plus.native.600s.KCs6m9UVB6YH10FkHzgP-g7Vq758GrhgaDMoOUhP7XY"
      },
      "streamSettings": {
        "network": "xdrive",
        "xdriveSettings": {
          "service": "local",
          "remoteFolder": "/tmp/xdrive-store",
          "sessionTtlSeconds": 30
        }
      }
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {
        "finalRules": [
          {
            "action": "allow"
          }
        ]
      }
    }
  ]
}

Client log

The client was killed with kill -9, so its log simply ends.

Details
Xray 26.10.17 (Xray, Penetrates Everything.) 92ccc93 (go1.27.1 darwin/arm64)
A unified platform for anti-censorship.
2026/10/20 13:20:14.259229 [Info] infra/conf/serial: Reading config: &{Name:client.json Format:json}
2026/10/20 13:20:14.259757 [Debug] app/log: Logger started
2026/10/20 13:20:14.259793 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:21005
2026/10/20 13:20:14.260017 [Info] transport/internet/tcp: listening tcp on 127.0.0.1:21005
2026/10/20 13:20:14.260034 [Warning] core: Xray 26.10.17 started
2026/10/20 13:20:16.261687 [Info] [2678353761] proxy/socks: TCP Connect request to tcp:127.0.0.1:18080
2026/10/20 13:20:16.261732 [Info] [2678353761] app/dispatcher: default route for tcp:127.0.0.1:18080
2026/10/20 13:20:16.261750 [Info] [2678353761] common/mux: dispatching request to tcp:127.0.0.1:18080
2026/10/20 13:20:16.261790 from tcp:127.0.0.1:54577 accepted tcp:127.0.0.1:18080 [socks >> proxy]
2026/10/20 13:20:16.262180 [Info] transport/internet/xdrive: opened session dcdedc90086e2e46b81de8a65fc1a85a
2026/10/20 13:20:16.262235 [Info] proxy/vless/outbound: tunneling request to tcp:v1.mux.cool:9527 via 127.0.0.1:22005

Server log

The client was killed at about 13:20:18.3. The server logged nothing after that; the folder reached 246,869,084 bytes / 607 objects by 13:20:38 and stayed there.

Details
Xray 26.10.17 (Xray, Penetrates Everything.) 92ccc93 (go1.27.1 darwin/arm64)
A unified platform for anti-censorship.
2026/10/20 13:20:13.253297 [Info] infra/conf/serial: Reading config: &{Name:server.json Format:json}
2026/10/20 13:20:13.254581 [Debug] app/log: Logger started
2026/10/20 13:20:13.254629 [Debug] app/proxyman/inbound: creating stream worker on 127.0.0.1:22005
2026/10/20 13:20:13.254977 [Warning] core: Xray 26.10.17 started
2026/10/20 13:20:16.488550 [Info] transport/internet/xdrive: accepted session dcdedc90086e2e46b81de8a65fc1a85a
2026/10/20 13:20:16.639683 [Info] [4248092209] proxy/vless/inbound: firstLen = 117
2026/10/20 13:20:16.639715 [Info] [4248092209] proxy/vless/inbound: received request for tcp:v1.mux.cool:0
2026/10/20 13:20:16.639723 [Info] [4248092209] common/mux: received request for tcp:127.0.0.1:18080
2026/10/20 13:20:16.639728 [Info] [4248092209] app/dispatcher: default route for tcp:127.0.0.1:18080
2026/10/20 13:20:16.639748 [Info] [4248092209] transport/internet/tcp: dialing TCP to tcp:127.0.0.1:18080
2026/10/20 13:20:16.639758 [Debug] [4248092209] transport/internet: dialing to tcp:127.0.0.1:18080
2026/10/20 13:20:16.639748 from tcp:127.0.0.1:0 accepted tcp:127.0.0.1:18080 [in >> direct]
2026/10/20 13:20:16.640021 [Info] [4248092209] proxy/freedom: connection opened to tcp:127.0.0.1:18080, local endpoint 127.0.0.1:54588, remote endpoint 127.0.0.1:18080
2026/10/20 13:20:16.640040 [Debug] [4248092209] proxy: CopyRawConn (maybe) readv

Activity

  1. thatssoheil commented on Oct 20, 2026

    @thatssoheil
    Contributor

    Reproduced at 92ccc939 (v26.10.17) with the configs and target from the report: local storage, 256 MiB body at 16 MiB/s, sessionTtlSeconds: 30, client kill -9 2 s in.

    store after kill+2s:  33,133,850 bytes    89 objects
    +8s:                 132,305,694 bytes   298 objects
    +16s:                242,290,542 bytes   576 objects
    +22s:                242,290,542 bytes   576 objects   (whole remaining body)
    

    The server logs nothing after the client is gone. Same shape as the report (246.9 MB / 607 objects), on this box with a local backend.

    Mechanism at main, confirming the trace: Listener.claim marks the session active (transport/internet/xdrive/xdrive.go:225) and only the connection's onClose clears it (:234); collect() skips active sessions (:267-269), so nothing is collected while the server-side connection lives. That connection ends only when the inbound handler returns, and nothing tests peer liveness: Conn.receive blocks on the reader channel (conn.go:53-61), walReader.poll returns quietly on an empty listing, holeTimeout needs a later segment to exist, EOF needs a .end object. On the write side there is no bound on unconsumed data: walWriter.Write buffers and flushLocked posts uploads (wal.go:73-91, :127-156); the semaphore in upload bounds concurrent Puts, not backlog.

    Plan (narrow, no protocol change - the peer already acks by deleting consumed segments):

    1. walWriter tracks which of its own segments the peer has not deleted yet. The check is a List of its own prefix, only while it has unconsumed segments and paced so a healthy reader costs no extra calls; it escalates to the poll interval once a cap is reached.
    2. Write blocks while more than N segments are unconsumed, so the inbound handler stops pulling from the target instead of filling storage (this is the missing backpressure).
    3. If the oldest unconsumed segment stays longer than holeTimeout, the connection closes with an error; onClose releases active and collect() drops the session.

    Tests: writer-level (blocks at the cap, resumes when the fake peer deletes, errors when nothing is deleted), listener-level (active released, folder collected), plus the reproduction above as the acceptance leg (storage stops growing at the cap, connection closes, folder is collected).

    If you would rather have an explicit heartbeat object per session, tell me and I will implement that shape instead. Branch: fix/xdrive-unconsumed-backpressure.

  2. thatssoheil commented on Oct 21, 2026

    @thatssoheil
    Contributor

    Prototype measured before pushing anything, and it surfaced a design question I would rather settle with you than guess.

    A writer-side cap on unconsumed segments (2 x concurrency, 16 segments / ~8 MB with defaults) turns the reproduction from 242 MB / 576 objects into 8.4 MB / 17 objects, frozen for as long as I watched; a normal 64 MiB download through the same build is unchanged. Good.

    But two things make that shape unfinished:

    1. The ack I use is the peer's delete of each segment, and that delete is best-effort in the current reader: walReader.discard drops names when its channel is full (wal.go:560-565). One dropped delete leaves an object that never disappears from the writer's listing, which pins a healthy writer at the cap forever.
    2. A Write blocked at the cap has no lifetime bound. With a dead peer the inbound handler never returns, so the session stays active and is never collected - the data is bounded, but the session is pinned. Today the handler finishes on its own and the session becomes collectable.

    So inferring consumption from deletes is not reliable enough to build on. The cleaner shape is an explicit ack: the reader publishes its last consumed sequence (one small object, refreshed per poll), and the writer uses that watermark for both the cap and a bounded stall close. The alternative is the heartbeat object from your option 2.

    Which would you prefer? I will implement that shape rather than push the delete-based prototype.

  3. RPRX commented on Oct 29, 2026

    @RPRX
    Member

    这个一般靠超时来控制,不过“约 2.7–13 分钟”有点离谱了,@4RH1T3CT0R7 你下一个 PR 顺便修一下

  4. RPRX commented on Oct 29, 2026

    @RPRX
    Member

    原因是 XDRIVE 既没有对端存活检测,也没有背压

    另外下个月整 Mux 可以弄带 padding 的双向 keep-alive 包,对端超时就清掉连接

    至于背压,减小的没有,但目前计划中会有“segment 自动逐轮增大” #7217 (comment) ,而这个机制就是依赖对端响应行为,可以先据此超时

    对于 @Ahmad-2213 的“Carry a Google Drive session in a ring of slots”,应该需要对端更新已有文件的 metadata,我不确定那个 PR 有没有

  5. anonymously-hidden commented on Oct 29, 2026

    @anonymously-hidden
    Contributor

    I actually Previously Added SegmentGrowthFactor; Then tried to Address your concerns one by one. most of my XDRIVE Folder is untouched & not brought into this repo.
    @4RH1T3CT0R7 may want to check them in his next PR.

    @RPRX the full capabilities are stored at https://github.com/Ahmad-2213/Xray-core/tree/main/transport/internet/xdrive
    I barely remember what I've addressed since then, but most of your concerns were addressed. (I'll double Check what I've done so far)

  6. RPRX commented on Oct 29, 2026

    @RPRX
    Member

    目前 main 的代码已实现我对 XDRIVE 的很多硬性要求,my concerns 主要就剩 #7217 (comment) 了,以及整 mux 和文档、教程,或许有文章

    全面优化延迟与速度后,不打游戏的话甚至可以日常用 XDRIVE,剩下的主要是 h2/h3 特征以及加些奇奇怪怪的 backend 吧,毕竟“滥用一切”

  7. anonymously-hidden commented on Oct 29, 2026

    @anonymously-hidden
    Contributor

    @RPRX
    my main repo consists ( some of them are not brought in #7217 ):

    Image
  8. RPRX commented on Oct 29, 2026

    @RPRX
    Member

    some of them are not brought in #7217

    我看那个 PR 的代码时已经注意到了,@4RH1T3CT0R7 的下一个 PR 对于 XDRIVE 而言会是质变

    另外我不确定 main 的 Google Drive 代码是否解决了该 issue 所述的问题,我觉得对端应当更新 metadata 来实现 ACK,不确定那个 PR 有没有

  9. anonymously-hidden commented on Oct 29, 2026

    @anonymously-hidden
    Contributor

    8. > some of them are not brought in #7217

    我看那个 PR 的代码时已经注意到了,[@4RH1T3CT0R7](https://github.com/4RH1T3CT0R7) 的下一个 PR 对于 XDRIVE 而言会是质变
    另外我不确定 main 的 Google Drive 代码是否解决了该 issue 所述的问题,我觉得对端应当更新 metadata 来实现 ACK,不确定那个 PR 有没有
    

    In my repo the reader ACKs by updating the description of a per-direction watermark file after each consumed segment. The writer rewrites a slot only once the watermark has reached seq - depth. If the watermark stops moving for 60 s the writer fails, so a dead client leaves at most 8 slot files and the session is released.

  10. RPRX commented on Oct 29, 2026

    @RPRX
    Member

    @Ahmad-2213 你检查下 Xray-core main 的代码,有要改的话和 @4RH1T3CT0R7 讨论下吧

  11. anonymously-hidden commented on Oct 29, 2026

    @anonymously-hidden
    Contributor

    The Google Drive ring (#7217) does the ACK by metadata: the reader updates the description of a per-direction watermark file when its head moves, and the writer reuses a slot only once the watermark has reached seq - depth. With at most 8 slots per direction and a 60 s stall timeout, a dead client no longer leaves hundreds of objects, so #7208 is solved for the Drive ring.

    what I found:

    1. await() in slots.go measures slotStallTimeout from the start of each wait, not from the last watermark progress. With depth 8 a reader that moves slowly makes each wait last about 8 segments of time, so a healthy but slow reader (below roughly 70 KB/s at 512 KiB segments) is failed after 60 s. Measuring from max(start, progress) fixes it. anonymously-hidden/Xray-core@cb7eff6
  12. anonymously-hidden commented on Oct 29, 2026

    @anonymously-hidden
    Contributor

    @RPRX made some optimizations. I finally managed to get a ping-time of 1200 ms on V2rayN after a hard work!
    youtube is smooth now and videos are easily loaded without buffering.
    @4RH1T3CT0R7 it's suggested to see the latest xdrive folder if you want to add commits.

    the config that i used ( note the relationship between mux and xdrive's ring concurrency):

     "segmentBytes": 524288,
    "segmentGrowthFactor": 1,
    "flushIntervalMs": 10,
    "pollIntervalMs": 50,
    "maxPollIntervalMs": 200,
    "eagerWindowMs": 4000,
    "holeTimeoutMs": 30000,
    "concurrency": 16,
    "sessionTtlSeconds": 300
    
    "mux": {
            "enabled": true,
            "concurrency": 32
          }
    

    AI Report:

    1. f5588d0c — build the whole slot ring in one parallel wave Session setup previously created slot files concurrently per direction but ran the watermark write and the second direction sequentially — ~4 sequential Drive round trips per new session. Now all slot files plus both watermarks are created in a single concurrent wave (index-addressed writes, mutex-guarded first error). Ring setup drops from ~4 Drive-latency rounds to ~1, which matters because traffic bursts open new rings.

    2. 75098023 — jump to full segments once the ring is three-quarters busy Fresh rings ramp segment size 14 KB → configured size (doubling every 8 full segments) so small or idle sessions stay cheap — inline segments ride the file description and cost one read. The downside was that a bursty fresh ring holds only 8×14 KB in flight and crawls until the ramp completes; a live 2 MB transfer over a fresh ring measured ~0.65 Mbps effective, with every multiplexed substream queued behind it. The jump-to-full-size now triggers at 75% ring occupancy instead of only at full saturation, so a bursty fresh ring widens a full ack-wave earlier instead of climbing most of the ramp ladder. A dedicated test discriminates the 75% path from the saturation path.

    3. efeaa641 — keep the reader fetch window flat Reverts an experiment from the same series that widened the reader's fetch window (6 → up to ring depth) while the session was recently active. The extra ahead-pollers kept issuing Drive reads during idle periods with no measurable latency benefit, so the window is back to a flat fetchAhead = 6 and idle quota burn returns to baseline.

    Net effect: fresh-ring ramp-up stalls — the dominant latency contributor when bursts open new rings — are largely removed, session setup is ~4× faster, and idle poll overhead is back to baseline. No config surface changed.

    Image
  13. anonymously-hidden commented on Nov 1, 2026

    @anonymously-hidden
    Contributor

    I actually have more enhancements on this; making it more browsing-friendly; Though i need to get home to implement them.I'll be home in 3-4 days
    I hope @4RH1T3CT0R7 & @Risaro are doing well.

    AI has never made it that easy, Ring slots were the claude's Idea, though the progress is slow due to quota usage

  14. RPRX commented on Nov 1, 2026

    @RPRX
    Member

    @4RH1T3CT0R7 像 @Risaro 一样没有回应了,让人很难不怀疑俄罗斯政府约谈了为 Xray-core 做出了贡献的个人开发者

  15. RPRX commented on Nov 1, 2026

    @RPRX
    Member

    @anonymously-hidden 看你个人隐私防护做得很好,你直接 PR 吧,XDRIVE 的进步不能停,这可能是最被 TSPU 忌惮的协议了

  16. 187 remaining items

  17. anonymously-hidden commented on Nov 28, 2026

    @anonymously-hidden
    Contributor

    AI ( Let's See what Chairman R will Respond to this Decisively ):

    Your 2 MB example held up. With two large downloads running, the predictive reader sustained 20.04–20.61 MB/s and opened new TLS connections faster than an otherwise identical reader that waited for a file lookup. My 128 KiB recommendation answered the wrong question: it kept latency down partly by limiting the downloads to 1.26–1.27 MB/s.

    You also proposed the fix for duplicate downloads: mark the frame READ(n) and replace its media body in the same update. I should have tested that before suggesting single-use IDs. On live Drive, changing only the description left the old 32,832-byte body downloadable. After the multipart read-and-clear update, all nine repeat GETs returned exactly 64 bytes.

    I reran the latency test on one XDrive session with unchanged VLESS/Mux, four HTTP/2 media connections, and a modeled 1 MiB window per connection with 150 ms credit return. That gives a theoretical 26.7 MiB/s; the fixture delivered 25.2 MiB/s on pipelined raw downloads. Across the comparisons, both bulk downloads made progress during every one of the 384 new TLS connections.

    Reader, 2 MiB per 100 ms Bulk goodput New TLS connection ready, p95 Short HTTPS response complete, p95
    Direct media GET by predicted ID 20.04–20.61 MB/s 3.28–3.40 s 6.49–6.56 s
    150 ms filtered list → media GET 20.52–20.70 MB/s 3.65–3.86 s 7.41–7.48 s
    750 ms filtered list → media GET 20.48–20.87 MB/s 4.87–4.95 s 9.69–9.78 s
    750 ms known-ID metadata GET → media GET 20.45–20.69 MB/s 5.01 s 9.58–9.81 s

    These are ranges across two local runs per path; the lookup delays were imposed, not measured inside Google. The key result is that bulk throughput barely changed, but a 750 ms serial lookup cost the new connection about 1.5–1.7 seconds to finish TLS and about 3.2 seconds to finish the HTTPS request. The lookup can recur as handshake and application bytes travel in both directions.

    For this design, I’d use 2 MiB as a ceiling, not a fill target: publish whatever is queued at the 100 ms tick, let the receiver GET the predicted ID directly, and retain the 64-byte read-and-clear marker. The byte-credit allowance must also cover the one-second reader lag: at 20 MB/s, that lag alone accounts for about 20 MB outstanding.

    One distinction matters for the shipped version: .110 normally reads a known slot’s metadata before fetching a large body; it does not list before every frame. The controlled comparison shows that either serial prerequisite can make other connections wait.

  18. RPRX commented on Nov 28, 2026

    @RPRX
    Member

    或者既然 AI 认同了我的路线更好,那直接用我的路线吧你测测,我本想把 AI 路线的极致也合并一下,仅作为历史记录,虽然但是 Short HTTPS response complete 需要六秒??TLS 1.3 握手加 HTTP 来回是两个 RTT,一个 RTT 就算顶格两秒也顶多四秒,让它自己想想哪里又被它搞错了

    另外我终于知道了为什么 1.5s 的 RTT 却阻碍了限制为 2s 的 Twitch 直播,原来 AI 是 list+get、把延迟搞上天了,我的路线或许解决了这个问题

  19. anonymously-hidden commented on Nov 28, 2026

    @anonymously-hidden
    Contributor

    AI ( I will test the newly added features soon ):

    Implemented the maintainer’s predictive media-GET protocol for Google Drive, with no compatibility decoder. Both peers must be upgraded together. The default is 100 slots per direction and up to 2 MiB per 100 ms tick. After ordered delivery, one multipart update marks the slot READ:n and replaces its body with the 64-byte marker.

    The maintainer was right about the two round trips. My mistake was assuming the prototype’s loaded RTT was at most two seconds. An echo over an already-open connection measured 3.04 s median during bulk downloads. The prototype waited one second in each direction before issuing the predicted GET and buffered the entire frame before delivery. TLS took roughly three seconds, then HTTP took another three. There was no third round trip or per-frame list in that six-second result.

    The implementation removes the fixed wait, adjusts GET timing from observed slot availability, and delivers verified 16 KiB blocks as they arrive.

    Two downloads on one session Fixed-delay prototype New implementation
    Bulk goodput 20.04–20.61 MB/s 20.34–20.67 MB/s
    New TLS connection ready, p95 3.28–3.40 s 1.82–1.83 s
    Short HTTPS response complete, p95 6.49–6.56 s 3.41–3.66 s

    These were local matching-peer tests. Both downloads continued transferring during all 48 new TLS connections in the two final runs.

    For the live-streaming question: on a reused HTTPS connection under bulk load, the new median echo RTT was 1.47 s. All 10/10 simulated 1.5 MiB live segments arrived within two seconds of release (1.35–1.98 s), versus 0/10 with the fixed-delay prototype. That supports the proposed mechanism; it does not establish what caused the original Twitch stalls.

    Live Drive verified two slot generations and their 64-byte clears. Race-enabled recovery tests passed, including delayed clears across ring reuse and a stalled final frame recovered in 5.03 s without duplicate bytes. The protocol README records 1,997 physical lines. XDrive vet and configuration tests passed; broader vet still reports pre-existing unreachable code at infra/conf/xray.go:756.

    Windows x64 build: G:\Cache\Temp\opencode\xdrive-media-implementation\windows-amd64\xray.exe. Changes are local; no commit, push, or release was made.

  20. Creeacher commented on Nov 28, 2026

    @Creeacher

    Following up on the XDRIVE performance discussion, I measured short HTTPS requests while two downloads ran through a full XDRIVE tunnel on v26.11.9, from a Moscow VPS to a Frankfurt VPS.

    • Google Drive completed 12/12 short probes and 4/4 downloads. Loaded p50/p95 was 2.31/2.62 s, with both downloads making progress during every probe.
    • Beget S3 completed 11/12 idle probes, at 3.23/5.97 s p50/p95. After starting the downloads, 0/12 short probes and 0/4 downloads completed within their respective deadlines.

    The two runs used different Mux and polling settings. They give two workload observations on the released build. A controlled build A/B and the client-disconnect scenario discussed in this issue remain outside these measurements.

    Full report, methods and anonymized CSVs

  21. RPRX commented on Nov 28, 2026

    @RPRX
    Member

    @Creeacher 后来的版本比 v26.11.9 的版本进步了很多,这也是我考虑要不要把某个版本仅作为历史记录合并进 Xray 的原因之一,仍在考虑中

    @anonymously-hidden 我看了下 README,设计的很多点与我预想的不同,不过你还是先测试下实际表现,至少先把实际体验和旧路线拉平

  22. RPRX commented on Nov 28, 2026

    @RPRX
    Member

    不过我必须吐槽是不是两千行还是给多了,AI 总把这玩意儿当成 TCP over IP 来设计干嘛?这底层是可靠文件系统、上层是 VLESS Encryption,所以这 CRC 咋又出来了显得 AI 有能耐? 乃至整个 frame 格式设计这玩意儿干嘛?本身就是有序、有已知文件大小,所以 header 全删了只留 payload,那个 FIN 也不是必要的,服务端删掉全部文件不就行了?客户端可以公告新连接但应只由服务端创建、删除文件,不过这个再说吧

  23. anonymously-hidden commented on Nov 29, 2026

    @anonymously-hidden
    Contributor

    I just Set up AI to do the work and I went to bed afterwards.
    Definitely it's different, I'll apply your notes, In fact, This AI should be told everytime, I've also measured again, it doesn't even transfer data. I'm trying to fix the flaws, apply your concerns and try again, This might take a while, it's kind of the same as introducing new things over the old versions, it needs testing and feedback to make it out again.
    I'll be implementing some of them that I can, then report them to you, mainly, AI can't fulfill all the things at once, it must be told exactly what to do, you may have to write a command for it again.

  24. svlavr commented on Nov 29, 2026

    @svlavr
    Contributor

    @anonymously-hidden, could you take a look at this local comparison against .113? I put the changes and focused tests in one commit. Feel free to pick up any part that looks useful. Comparison commit

    The main changes reduce copying and allocations. On writes, the sender borrows each chunk until the accumulator has copied it. In the 2 MiB handoff benchmark, that removed 32 temporary allocations. On reads, if Drive returns a full HTTP 200 in response to Range, the reader reuses scratch space to verify the prefix it already delivered. With 75% of a 2 MiB frame replayed, allocations fell from 131 to 12.

    The commit also removes a full-frame copy when building multipart uploads, uses a metadata-only READ:n for EMPTY, and simplifies announcement cleanup. It keeps the .113 wire format, CRC, and Range recovery. I verified both pairings with stock .113, including recovery from an interrupted read and a lost PATCH reply. I did not see a consistent end-to-end speedup in the local fixture, so the result I can point to is lower allocation cost.

  25. anonymously-hidden commented on Nov 29, 2026

    @anonymously-hidden
    Contributor

    I've Ran Out of Quota Again
    I've tried to implement what RPRX actually wants, @svlavr Let me apply and release .114, then that comparison would indeed be useful on new version.
    AI:

    .113 still has CRC-32C, per-block headers, and FIN. I’ll replace those with raw media bodies and server-owned data files, keep the client’s creation rights to its announcement, and test both interrupted reads and close with the last payload still in flight.

    @RPRX If other than these changes or perhaps, misunderstandings by AI needs to be corrected and implemented, you may tell me.

    Regarding a Stable version, the choice is yours after All, Keep in mind that later versions e.g. .111 do not use the previous method, and they're eventually going to converge into raw direct method as you've explained and they're also in the test phase & under implementation & are not suitable for ordinary usage yet.

    in the new version that shall be released later, instead of slots.go, we'll have raw.go

  26. svlavr commented on Nov 29, 2026

    @svlavr
    Contributor

    @anonymously-hidden, one thought on quota. I don’t know how you have OpenCode set up, but what’s worked for me is to keep GPT-6.2 Astra in the main conversation for architecture and decisions that affect the whole task. I use GPT-6.2 Sol with reasoning set to high for most of the hands-on work, like tracing code paths, making changes, running tests, and reviewing diffs. Sol handles most of that well, and this setup helps me stretch my quota.

  27. anonymously-hidden commented on Nov 29, 2026

    @anonymously-hidden
    Contributor

    Indeed, even before using these powerful models, I used to use GPT-6.1 Sol, though now even with GPT-6.2 Astra, Most of the implementations are revised by @RPRX , I can't take the risk on using GPT-6.2 Sol which is a less stronger Model.

    image
  28. svlavr commented on Nov 29, 2026

    @svlavr
    Contributor

    @anonymously-hidden, following up on the DevKit I mentioned earlier. I’ve updated the setup I use with skills and reviewer roles based on public PRs and discussions by RPRX, Fangliding, Meow, and others. Feel free to look through the whole kit. For .114, I’d try these three first. DevKit update

    • xray-rprx-review helps check the implementation against what RPRX proposed. For .114, I’d ask the agent to trace who creates and deletes the files and what tells the reader that the last bytes have arrived. Skill
    • xray-code-analysis helps find the Go code that relies on the frame header and FIN. That makes it easier to see which checks and waits need to carry over when the file body becomes raw payload. Skill
    • xray-fangliding-review helps check the new path through a normal Xray run. I’d start with the two cases you already mentioned, an interrupted read and a close while the last bytes are still in flight. In both cases, check exactly which bytes the client received and how the stream ended. Skill
  29. anonymously-hidden commented on Nov 29, 2026

    @anonymously-hidden
    Contributor

    I might need to set this up later, right now, I'm overwhelmed with bunch of personal deeds, I need to handle them and take my time on this; for now, I can only work with ordinary AI Work; The instructions should Also take affect, ( I hope you could issue it for OpenCode aswell )

  30. svlavr commented on Nov 29, 2026

    @svlavr
    Contributor

    @anonymously-hidden, I’d configure the skills and agents first, then pick a model for each role. I’d save Astra for the tasks that need it. For example, figuring out which two lines to change might take Astra. Once the change and the check are clear, Sol or even Terra can make the edit and verify it. That’s where a setup with defined roles and skills helps stretch the quota.

    An OpenCode kit is a good idea. I’ll try to put one together soon.

  31. RPRX commented on Nov 29, 2026

    @RPRX
    Member

    我认为对于 @anonymously-hidden ,现在不是建议他换到另一种方式的好时机,maybe next time,另外我还是先挑个版本发个 v26.11.29 吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions