M4: WebRTC server-hop latency p95 gate #9
Loading…
Reference in a new issue
No description provided.
Delete branch "m4-latency-gate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Second half of M4: a CI-enforced latency p95 gate. Stacks on PR #8 so the workflow file gets the new job in one merge.
What it measures
End-to-end RTP arrival latency from
corewebrtc.Sourceingest through Pion DTLS-SRTP to a subscriber'strack.ReadRTP(). Synthetic publisher embedstime.Now().UnixNano()in each RTP payload; subscriber diffs againsttime.Now()on arrival.Exercises every link the egress code path can regress:
Source.readLoopUDP read + RTP unmarshalforwardRTPSplitgoroutineTrackLocalStaticRTP.WriteRTPTrackRemote.ReadRTPunmarshalWhat it doesn't measure (and why)
The design's §7 calls for true glass-to-glass latency:
drawtextframe counter on the publisher, decode-side pixel sampling on the subscriber, p95 < 300ms (RTMP) / < 200ms (SRT). Implementing that in pure Go would need a cgo H.264 decoder or an FFmpeg-as-sidecar pipe — a much bigger lift for marginal regression-detection value, since encode/decode latency is fixed by the codec stack and isn't moved by Core code changes.The server-hop measurement captures everything Core code can actually regress.
Threshold
p95 < 50 ms. Locally observed on a quiet host:So the gate is ~200× headroom — generous enough to absorb CI runner noise without false alarms, tight enough to catch a real slowdown.
Implementation notes
//go:build latency) so it doesn't run in the defaultgo test ./...invocation.latencySamplesuses async.Mutexaround the slice append because the receive goroutine and test goroutine race otherwise (vet caught this on the first draft).latency-gatejob in.forgejo/workflows/test.yml, parallel withtestandwebrtc-smoke, depends onlint-and-vet.test/TESTING.mdwith expected numbers and the rationale.Files
Co-authored with Claude Opus 4.7.
Merged into
mainvia direct push as part of the v0.1.0-dragonfork release. Branch commits are reachable from main; closing this PR. Release: https://forge.wilddragon.net/zgaetano/datarhei-dragonfork-core/releases/tag/v0.1.0-dragonforkPull request closed