Add packet to forwarding stats only if packet is forwarded. (#4056)

Packets not being forwarded were getting included in forwarding stats
calculation and skewing the measurement towards a smaller number.

The latency measurement does not include the batch IO of packets on
send. With a 2ms batching, that will add an average latency of 1ms.
This commit is contained in:
Raja Subramanian
2025-11-06 12:31:49 +05:30
committed by GitHub
parent f6909192bb
commit ae5fb7e882
10 changed files with 73 additions and 57 deletions
+2 -3
View File
@@ -86,10 +86,10 @@ func (d *DownTrackSpreader) HasDownTrack(subscriberID livekit.ParticipantID) boo
return ok
}
func (d *DownTrackSpreader) Broadcast(writer func(TrackSender)) int {
func (d *DownTrackSpreader) Broadcast(writer func(TrackSender)) {
downTracks := d.GetDownTracks()
if len(downTracks) == 0 {
return 0
return
}
threshold := uint64(d.params.Threshold)
@@ -101,7 +101,6 @@ func (d *DownTrackSpreader) Broadcast(writer func(TrackSender)) int {
// WriteRTP takes about 50µs on average, so we write to 2 down tracks per loop.
step := uint64(2)
utils.ParallelExec(downTracks, threshold, step, writer)
return len(downTracks)
}
func (d *DownTrackSpreader) DownTrackCount() int {