curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Large download speed deviations for CURLOPT_MAX_RECV_SPEED_LARGE in 8.4.0

From: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Date: Fri, 8 Dec 2023 19:42:39 +0000

Yes, it has the same effect.
I was thinking about the same way but was hesitating to make the "max_recv" go below zero after "max_recv -= blen", but now I see that it is OK and such cases are properly covered.

Your solution is smaller and better than mine, we probably just need to add a comment explaining why we set the "max_recv" to zero if the speed limit is set.

Besides improved speed precision, this solution also makes CPU less "bursty" when the speed limit is set,
because data reading and processing times are now better mixed with smaller waiting times imposed by the speed limit.

Thanks,
Dmitry Karpov


-----Original Message-----
From: Daniel Stenberg <daniel_at_haxx.se>
Sent: Friday, December 8, 2023 7:29 AM
To: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Cc: Dmitry Karpov <dkarpov_at_roku.com>
Subject: [EXTERNAL] Re: Large download speed deviations for CURLOPT_MAX_RECV_SPEED_LARGE in 8.4.0

On Tue, 5 Dec 2023, Dmitry Karpov via curl-library wrote:

> With this patch, I was able to get quite precise speed limitations
> (under 0.5% on average) for different socket buffers and speed limits.

Isn't this the same effect with a smaller change?

--- a/lib/transfer.c
+++ b/lib/transfer.c
_at__at_ -430,12 +430,11 _at__at_ static CURLcode readwrite_data(struct Curl_easy *data,
    CURLcode result = CURLE_OK;
    char *buf;
    size_t blen;
    size_t consumed;
    int maxloops = 100;
- curl_off_t max_recv = data->set.max_recv_speed?
- data->set.max_recv_speed : CURL_OFF_T_MAX;
+ curl_off_t max_recv = data->set.max_recv_speed ? 0 : CURL_OFF_T_MAX;
    bool data_eof_handled = FALSE;

    DEBUGASSERT(data->state.buffer);
    *done = FALSE;
    *comeback = FALSE;

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-12-08