cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Download Averaging Issue

From: Rob Ward <rob_at_rob-ward.co.uk>
Date: Sun, 20 Nov 2011 12:15:41 +0000

On 19 November 2011 21:45, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Fri, 18 Nov 2011, Rob Ward wrote:
>
> I saw that curl was stored the data of the average for the last 5 seconds
>> and looked at using this as a potential solution. However if the download
>> speed was 10meg (max out the connection) and after this point the max speed
>> was set to 1meg then it would be 6 seconds(if I did my maths right) before
>> the download would resume
>>
>
> Right, but I think it is mostly a matter of understanding and documenting
> the behavior and adjusting your code to that.
>
> If you get 10/sec and suddently sets max transfer rate down to 1/sec, at
> that moment you should have roughly 9 too many for that second and it would
> take about 9 seconds until you need more data again. I don't think that is
> a completely wrong way to see it.
>
> I figure you mean that when you set the new rate to 1/sec you should get 1
> data during following second, disregarding what was delivered the previous
> second. To make that work, I figure either an internal timer or data count
> need to be reset when you change the value.
>
> Or did I misunderstand ?
>
>
> --
>
> / daniel.haxx.se
>

Yes that is correct, that is the current behaviour(and it is well
documented). I am just trying to work out what the best internal solution
would be, I could do it in the application by getting the download time and
amounts and doing maths in the application to workout the max receive speed
required to get the minimum amount however I would prefer a solution in
curl so others can use it as it seems like a piece of functionality many
could use in the future.

With regards to resetting a timer/data the only way I can see of doing this
without effecting the current behaviour of curl is to add a reset option
that would store the current downloaded amount and download time that can
be used as an offset within the calculations for the current average. I am
however unsure what negative effects this might have on other areas of curl
or if it is the best way. Any advice with regards to possible side effects
would be appreciated.

The other solution that appears relatively simple and as far as I can see
would have little impact on any other code is to have another option
that specifies a minimum desired download rate, then where the average
speed is used to decide if a delay should be inserted before downloading
more data this can be checked, and if the current rate is below it will
continue without delay irrespective of the average speed calculations.

Regards,

Rob

-- 
------------------------------
Rob Ward
www.rob-ward.co.uk

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-20