feat: record the first join as a latency DAG (3RTT T01) - #7
Merged
Merged
Conversation
Call.ConnectionTiming and Call.OnConnectionTiming expose when the coordinator join, the SFU websocket and join, and each peer connection's signaling, ICE, DTLS and first RTP happened, so callers can print where connection setup time goes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Delays every write and read by rtt/2 in order, and a TCP connect by one rtt, on stream conns, packet conns and a pion transport.Net for ICE. For tests and benches only.
…dialer Reports TLS, request and first-byte times to the context's httptrace.ClientTrace, and leaves DNS and connect to the dial function, as net/http does.
Replaces ConnectionTiming with jointrace: each step of the join is a span with its dependencies, kind (net, local, timer) and peer, so the trace shows which branches run in parallel and which chain is critical. - Call.JoinTrace and Call.OnJoinTrace, fired when media flows both ways or after JoinTraceTimeout. - httptrace detail (DNS, TCP, TLS, request, first byte) for the coordinator REST call, the coordinator and SFU websockets and the SFU RPCs; Server-Timing when the server sends it. - RTT per peer from the TCP connect and the ICE selected pair; every network span is also expressed in round trips of its peer. - Trace.String draws the DAG with the critical path marked; the trace marshals to a JSON report. - WithNetworkDelay, for tests and benches: every connection the client opens, UDP included, behaves as if it crossed a network with that RTT. - signal.WithDialContext and signal.WithTLSConfig; testutil.WithTLS.
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.
3RTT task T01. Replaces
ConnectionTiming(folds in #2) withjointrace: the first join is recorded as a DAG of spans, so a trace shows which steps run in parallel, which chain is critical, and every network step in round trips of its peer. Builds on #5.What's in it
jointracepackage:Span{Name, After, Parent, Start, End, Kind, Peer, Note}, with the node names fromresearch/join-dag.mdas constants.Trace.CriticalPath()walks back from the terminal step (pub.rtp/sub.rtp), following the dependency that finished last.Trace.String()draws the DAG with a gantt column and marks the critical path;json.Marshal(trace)gives a flatReport.Call.JoinTrace()andCall.OnJoinTrace(fn). The handler fires once media flows both ways, or afterJoinTraceTimeout. Reconnects after the first join seal the trace..dns,.tcp,.tls,.request,.first_byte) on:internal/wsdial,.serverspan fromServer-Timingwhen the server sends one.WithNetworkDelay(rtt), for tests and benches only. Every connection the client opens is delayed rtt/2 each way, in order, and a TCP connect takes one RTT. This covers coordinator REST and WS, the location hint, SFU WS and twirp, and ICE UDP viaSettingEngine.SetNet.signal.WithDialContext,signal.WithTLSConfig,testutil.WithTLS().Tests
jointrace: the critical path through parallel branches, gaps counted as wait, a JSON round trip, a render golden (go test ./jointrace -update), httptrace phases and Server-Timing over a delayed TLS server, a traced wss dial at 3 RTT, and a recording cost check (< 1 ms per join).internal/netdelay: TCP connect and echo, and UDP echo, each 100 ms ± 5%; order kept over 500 writes; deadlines.fakesfuwith real pion peers both ways:WithNetworkDelay(100ms)over TLS:sfu.ws.dialis 3 RTT andsfu.joinis 1 RTT, each ± 10%, and the SFU and UDP RTTs are 100 ms ± 10%.make ciis green.Example (fake SFU over TLS,
WithNetworkDelay(100ms)):