[mythtv] Small code improvement.

michael at optusnet.com.au michael at optusnet.com.au
Sun May 11 18:13:33 EDT 2003


Isaac Richards <ijr at po.cwru.edu> writes:
> On Saturday 10 May 2003 10:18 pm, michael at optusnet.com.au wrote:
[...]
> > so no matter how much read-ahead you do, you can't saturate a higher
> > latency network link without windowing the requests. (given that a
> > typical remote machine can have 20 ms or more of latency, I care
> > about this :)
> 
> How's that?  All you're doing is stuffing data in the QSocket's internal 
> buffer instead of storing it in the prebuffer thread's buffer.

The idea is to have at least N more requests issued than you've
received. If you issue 1 request, and then wait for it to arrive
you pay the full latency price and your link utilization is
correspondingly terrible.

If instead you issue 5 requests before waiting for the first to 
arrive back, and ensure that there at least 5 outstanding
requests at all times, you'll get much much better link utilization.

> > Would you object if I at least moved all the magic numbers to
> > variable, and consolidated them in one place?
> 
> Yes.

Hmm. That's helpful. :) Could you expand on why that would be
a problem? At the moment it's very difficult to fix problems
I'm seeing because there is so much buried magic.

For example, if I press "forward 10 mins" the video freezes
for approx 20 seconds before playing. Why is this? No
disk activity happens, no CPU is used, it just hangs for
20 seconds.

[..]
> > In RingBuffer::safe_read(int,void*,int) when the read()
> > gives EOF, why does it try another 20 times before
> > failing? (I notice similar code in lots of other
> > places).
> 
> read() doesn't tell you it's at eof, it just says it didn't read anything.  
> You get the same return if you're reading at the end of a file and waiting 
> for more data to fill.

read() returning 0 is reliably EOF. That's the spec.

For the reaching the end of data case and waiting for more data,
why do you only wait 20 ms for more data? Doesn't you need to
wait 50ms to be guarenteed another video frame?


More information about the mythtv-dev mailing list