Repository navigation
gRPC: drop media and poses queued past a delay, measured by in-band probes - #1006
Merged
Merged
Conversation
…robes A gRPC Write returns once HTTP/2 flow control and the socket take the bytes, and BDP probing grows the window to megabytes, so during a TCP loss burst no write blocks, the media stall drop never fires, and seconds of camera, mic and pose traffic queue per viewer. Writers of loss-tolerant frames (the media fan, a node's own uplink, pose snapshots) now follow them with a Ping whose seq has the top bit set, at most every 50 ms. The stream is in order, so its Pong answers every earlier probe; the oldest unanswered one dates the oldest byte that may still be queued. Past the base round trip (the least probe round trip over 10 s) by more than set_media_delay_drop (default 100 ms), video to that receiver is dropped, pose snapshots past twice that and audio past four times. A peer that never answers a probe is never held back. Also: - a Pong goes through the admission hold (a held stream left probes unanswered); - push_pose_snapshot_to waits at most 1 ms for a busy stream, and the heartbeat skips one, instead of blocking the caller; - each dialed peer gets its own connection (a local subchannel pool), so two transports dialing one relay no longer share a flow-control window and every TCP stall; - arisrv and arisrv_aoi_bench take --media-delay-ms; the bench reports the drops (relay fan, uplinks) and the skipped pose snapshots.
…ackoff on a thinned stream)
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.
Under bursty loss, the gRPC transport queued seconds of camera, mic and pose traffic per viewer. Now it drops the stale frames, so a loss burst costs a few dropped frames, not a multi-second backlog.
Why it queued
connection::writecalls a synchronousWrite. That returns once HTTP/2 flow control and the socket take the bytes.stalled 0in every master run below.The fix: in-band queue probes and a delay drop
Pingwhose seq has the top bit set. That covers the relay's media fan, a node's own uplink, and pose snapshots. At most one goes out every 50 ms, after at least 1 KB more was written, with at most 8 outstanding.Pongmeans the peer has read everything written before it. The oldest unanswered probe therefore dates the oldest byte that may still be queued. Its age minus the base round trip is the queue delay. The base round trip is the smallest probe round trip over the last 10 s.set_media_delay_drop(ms), default 100 ms. Past that queue delay, the receiver's video is dropped, its pose snapshots are skipped past 2×, and its audio past 4×. Those are the WebSocket transport's ratios: a backed-up link sheds video first.Ping, so old clients need nothing.Pongnow goes through the admission hold. A held stream used to leave probes unanswered.push_pose_snapshot_toruns on the relay's room step. It now waits at most 1 ms for the stream lock and then skips; the next snapshot carries what it would have.try_write.GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL). gRPC otherwise carries every channel in a process to the same target on one HTTP/2 connection. The bench's two clients were sharing one TCP connection, its flow-control window and every TCP stall, which two separate clients never do.arisrv --media-delay-ms N(0 = off);arisrv_aoi_bench --media-delay-ms Nsets the relay and the clients. The bench now reports the drops (relay fan, uplinks) and the skipped pose snapshots.Results
Setup
delay 20ms loss gemodel 1% 30% 100% 0%(about 3 % loss in bursts of about 3 packets).arisrv_aoi_bench --transport grpc --clients 2 --camera-hz 15 --video-bytes 5400 --mic opus --seconds 30 --warmup 4 --client-hz 60, in both pose modes.delay 20ms, no loss) have 2 runs each.Camera p95 per run, in ms:
Approaches evaluated
Same setup, 6 runs per row. Three builds were added:
tcp_thin_linear_timeouts: this PR withnet.ipv4.tcp_thin_linear_timeouts=1set in the namespace.The first two ran from an experiment-only build: env-gated channel args, not in this PR.
tcp_thin_linear_timeoutstcp_thin_linear_timeoutsWhat the comparison shows:
stalled 0).tcp_thin_linear_timeoutsadds little on top here. The separate connections already removed the long RTO stalls from these 12 runs. One stream run still had pose age p95 of 1.4 s.What I found along the way
ss -tinshowedbackoff:6 rto:15616 cwnd:1, with every retransmission dropped. gdb showed every reader idle incq_pluck, so it was not a deadlock.net.ipv4.tcp_thin_linear_timeouts=1stops the RTO doubling for thin streams. It is per network namespace, and with it 8 of 8 shared-connection tree runs ran clean. On the relay host it would be cheap insurance. That is a deployment change, not done here.Tests
state_transport_grpc_test: 50 passed, 3 skipped (TLS, stress, perf), on Windows (static MSVC build) and Linux (catx-03). It includes the newProbeQueueDelayandDelayDropSkipsAStalledReceiver(a receiver whose reader stalls 1.2 s: the sender drops media and skips poses, then delivers again once it catches up).room_relay_integration_test16,room_aoi_relay_test10,stream_relay_test3,room_media_test2,pose_stream_test9, all pass.Not done
No production deploy; that needs a go-ahead.