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 503262 - queue2 in/out rate updating not needed when queue full/buffering
queue2 in/out rate updating not needed when queue full/buffering
Status: RESOLVED INCOMPLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-12-12 13:41 UTC by Tommi Myöhänen
Modified: 2010-01-14 19:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstqueue2.c.rate_update.patch (678 bytes, patch)
2007-12-12 13:42 UTC, Tommi Myöhänen
none Details | Review

Description Tommi Myöhänen 2007-12-12 13:41:03 UTC
I think queue2 byte_in_rate shouldn't be updated when the queue2 is full, i.e. when no data flows to queue2. If queue2 stays full for a while for some reason it will cause increase in cur_level.rate_time making it "even fuller" and might unnecessarily prevent data flowing in. Furthermore if byte_in_rate is to be used to estimate available network bandwidth then queue2 fullness shouldn't affect it.

Also if byte_out_rate is to be used to estimate stream byterate, then it could be updated only when pipeline is playing, i.e. not when buffering and paused.
Comment 1 Tommi Myöhänen 2007-12-12 13:42:29 UTC
Created attachment 100829 [details] [review]
gstqueue2.c.rate_update.patch
Comment 2 Tommi Myöhänen 2007-12-12 13:57:25 UTC
For clarification, the mentioned increase in cur_level.rate_time when queue2 is full, comes from the way rate_time is calculated:

queue->cur_level.rate_time =
    queue->cur_level.bytes / queue->byte_in_rate * GST_SECOND;

Comment 3 Tommi Myöhänen 2007-12-13 11:21:01 UTC
To further clarify this issue, here are some steps how this problem might occur:

1. queue2 remains full for a while during playback. (The reason could be e.g. badly demuxed file causes demuxer to block for a while or something else)

2. while the queue2 is full, no data flows in but time elapses -> byte_in_rate drops

3. when byte_in_rate drops, cur_level.rate_time increases, because of the way it is calculated

4. next when data starts flowing out again, cur_level.rate_time might have increased well over max_level.rate_time and so queue2 still refuses to accept more data just because it was full for a while. And because no data is accepted byte_in_rate keeps dropping further. Recovery from this will happen when enough bytes have flown out of queue2.

Another issue is that if byte_in_rate/byte_out_rate are to be used to estimate network bandwidth/stream byterate, then we could exclude these special cases where data is not flowing through the queue "normally" i.e. when queue2 is full (no data flowing in) and while buffering and paused (no data flowing out). Because during these special cases the in/out rates don't actually reflect bandwidth/stream byterate. Using average values makes these problems less significant, but I think the accuracy of the avg values could be improved this way.
Comment 4 Wim Taymans 2007-12-13 16:04:57 UTC
It seems that we should not update the timer when we are blocking in the queue because it is filled. This will make sure we only measure the real input rate without the time we spend on blocking.
Comment 5 Jan Schmidt 2007-12-14 00:02:52 UTC
(In reply to comment #4)
> It seems that we should not update the timer when we are blocking in the queue
> because it is filled. This will make sure we only measure the real input rate
> without the time we spend on blocking.
> 

Hey, that's exactly what I was going to say. Conversely, for output rate, it's the elapsed time minus the time spent blocking for buffers to be available.
Comment 6 Wim Taymans 2007-12-14 09:25:10 UTC
Ok, that part I understood. Now for the next part...

        * gst/playback/gstqueue2.c: (gst_queue_chain):
        Pause the timer to measure the input rate when we block because the
        queue is filled. See #503262.
Comment 7 Tommi Myöhänen 2007-12-14 10:48:25 UTC
Okay, that should fix the problem with the byte_in_rate. Although, pausing the timer prevents also updating byte_out_rate which we actually should do despite queue is full. On the other hand now there should not be much data (in bytes) flowing out of the queue while full. Unless someone e.g. halves max_level.bytes during playback in which case byte_out_rate measuring will probably get a bit screwed.
Comment 8 Wim Taymans 2007-12-14 18:46:47 UTC
Ok, having separate timers makes sense to me. Now whatfor and how would we actually use the output_rate :)

        * gst/playback/gstqueue2.c: (gst_queue_init), (gst_queue_finalize),
        (reset_rate_timer), (update_in_rates), (update_out_rates),
        (gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
        (gst_queue_chain), (gst_queue_loop):
        Use separate timers for input and output rates.
        Pause measuring the output rate when we block for more data.
        See #503262.
Comment 9 Tommi Myöhänen 2007-12-19 10:05:27 UTC
Good question :) maybe it could be used to size the queue2 "better" when playing high bitrate content over low bandwidth connection. Or should this kind of scenario be supported at all, should we just error out?
Comment 10 Sebastian Dröge (slomo) 2009-07-30 13:15:10 UTC
The attached patch seems to be obsolete now, right? Also, this bug itself seems to be fixed since December 2007 or is there still anything to do?
Comment 11 Sebastian Dröge (slomo) 2010-01-14 19:53:22 UTC
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information asked for.
Thanks!