From 1da640abb6886aab822ff0c0da71b1df0ca89d0f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 11 Dec 2023 19:36:27 +0100 Subject: [PATCH] readwrite_data: loop less This function is made to loop in order to drain incoming data faster. Completely removing the loop has a measerably negative impact on transfer speeds. Downsides with the looping include - it might call the progress callback much more seldom. Especially if the write callback is slow. - rate limiting becomes less exact - a single transfer might "starve out" other parallel transfers - QUIC timers for other connections can't be maintained correctly The long term fix should be to remove the loop and optimize coming back to avoid the transfer speed penalty. This fix lower the max loop count to reduce the starvation problem, and avoids the loop completely for when rate-limiting is in progress. Ref: #12488 Ref: https://curl.se/mail/lib-2023-12/0012.html Closes #12504 --- lib/transfer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/transfer.c b/lib/transfer.c index d92b7edd41..3afefd4dfc 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -427,9 +427,8 @@ static CURLcode readwrite_data(struct Curl_easy *data, 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; + int maxloops = 10; + curl_off_t max_recv = data->set.max_recv_speed ? 0 : CURL_OFF_T_MAX; bool data_eof_handled = FALSE; DEBUGASSERT(data->state.buffer); -- 2.47.3