After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 751636 - rtpjitterbuffer: wastes CPU processing too many unnecessary timers
rtpjitterbuffer: wastes CPU processing too many unnecessary timers
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 740149
 
 
Reported: 2015-06-29 08:38 UTC by Miguel París Díaz
Modified: 2018-11-03 15:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch (1.32 KB, patch)
2015-06-29 09:05 UTC, Miguel París Díaz
none Details | Review
rtpjitterbuffer: If possible, always update the current time before looping over all timers (1.67 KB, patch)
2015-06-29 10:02 UTC, Sebastian Dröge (slomo)
none Details | Review
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch (1.32 KB, patch)
2015-06-29 14:12 UTC, Miguel París Díaz
none Details | Review
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch (1.37 KB, patch)
2015-06-29 14:14 UTC, Miguel París Díaz
none Details | Review
rtpjitterbuffer: If possible, always update the current time before looping over all timers (6.41 KB, patch)
2015-06-29 14:35 UTC, Sebastian Dröge (slomo)
committed Details | Review
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT (2.70 KB, patch)
2015-07-02 16:26 UTC, Sebastian Dröge (slomo)
none Details | Review
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT (2.34 KB, patch)
2015-07-02 16:30 UTC, Sebastian Dröge (slomo)
none Details | Review
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT (2.34 KB, patch)
2015-07-02 16:35 UTC, Sebastian Dröge (slomo)
none Details | Review
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT (2.41 KB, patch)
2015-07-02 16:38 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Miguel París Díaz 2015-06-29 08:38:31 UTC
I have found a case where the jitterbuffer gets a lot of timers and it spends a lot of CPU processing them.
I open this bug to provide some patches to fix this problem.
Comment 1 Miguel París Díaz 2015-06-29 09:05:10 UTC
Created attachment 306268 [details] [review]
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch
Comment 2 Sebastian Dröge (slomo) 2015-06-29 09:21:05 UTC
Related to this also http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=de5cd0995bfa9fe7852532573e0b7cab9498725a

Putting the timers into a sorted data structure is not too trivial though:
- get_timeout() depends not only on the timeout but also on the latency property, ts-offset and out_offset (buffering mode). This could be solved be resorting the complete sequence whenever those change (which happens not too often hopefully, and usually shouldn't change the order so should be O(n))

- timers are searched for by (type, seqnum) and pointer value. If we sort the timers by (timeout, seqnum), then these other two would be O(n) again. We could add two hash tables for that, but that also seems too much overhead.
Comment 3 Sebastian Dröge (slomo) 2015-06-29 09:45:01 UTC
Comment on attachment 306268 [details] [review]
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch

This doesn't seem right as it considers all possible timers. Some timer types shouldn't be considered a gap (the expected timers for future packets)
Comment 4 Sebastian Dröge (slomo) 2015-06-29 10:02:06 UTC
Created attachment 306271 [details] [review]
rtpjitterbuffer: If possible, always update the current time before looping over all timers

If we have a clock, update "now" now with the very latest running time we have.
If timers are unscheduled below we otherwise wouldn't update now (it's only updated
when timers expire), and also for the very first loop iteration now would otherwise
always be 0.
Comment 5 Miguel París Díaz 2015-06-29 14:12:52 UTC
Created attachment 306292 [details] [review]
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch
Comment 6 Miguel París Díaz 2015-06-29 14:14:42 UTC
Created attachment 306293 [details] [review]
0001-gstrtpjitterbuffer-consider-timers-len-to-compare-wi.patch
Comment 7 Sebastian Dröge (slomo) 2015-06-29 14:35:20 UTC
Created attachment 306296 [details] [review]
rtpjitterbuffer: If possible, always update the current time before looping over all timers

If we have a clock, update "now" now with the very latest running time we have.
If timers are unscheduled below we otherwise wouldn't update now (it's only updated
when timers expire), and also for the very first loop iteration now would otherwise
always be 0.
Comment 8 Sebastian Dröge (slomo) 2015-07-02 16:26:58 UTC
Created attachment 306648 [details] [review]
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT

When there are a lot of small gaps, we can consider that there is
a big gap (too losses) to reset the buffer.
Comment 9 Sebastian Dröge (slomo) 2015-07-02 16:30:54 UTC
Created attachment 306649 [details] [review]
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT

When there are a lot of small gaps, we can consider that there is
a big gap (too losses) to reset the buffer.
Comment 10 Sebastian Dröge (slomo) 2015-07-02 16:31:31 UTC
What about this? Your patch before would've never reset in case we had: big gap, 1 packet, big gap, 1 packet, etc.. Before resetting it would wait for 5 consecutive seqnums, which would never happen in this case.
Comment 11 Sebastian Dröge (slomo) 2015-07-02 16:35:44 UTC
Created attachment 306652 [details] [review]
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT

When there are a lot of small gaps, we can consider that there is
a big gap (too losses) to reset the buffer.
Comment 12 Sebastian Dröge (slomo) 2015-07-02 16:38:56 UTC
Created attachment 306653 [details] [review]
rtpjitterbuffer: Consider timers len to compare with RTP_MAX_DROPOUT

When there are a lot of small gaps, we can consider that there is
a big gap (too losses) to reset the buffer.
Comment 13 Sebastian Dröge (slomo) 2015-07-02 17:34:16 UTC
For making the timer handling more efficient we could probably go with two GSequences. One sorted by (< seqnum), the other sorted by (< (timeout, seqnum)). The second needs to be resorted whenever the properties change. Both can be used to find by "ptr" by just looking for the seqnum / timeout value.
Comment 14 Sebastian Dröge (slomo) 2018-05-07 14:45:18 UTC
The Pexip folks also presented something based on a proper priority queue at the GStreamer conference. It would be good to get that merged here.

What's the status of that?
Comment 15 GStreamer system administrator 2018-11-03 15:01:37 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/197.