From df9829783f144c57e06b5d08f7643d9720f4cca8 Mon Sep 17 00:00:00 2001 From: John Thiltges Date: Thu, 21 Mar 2019 09:58:10 -0500 Subject: [PATCH] [XrdTpc] Only use Curl's low-speed-limit with libcurl v7.38 and later Curl's detection of low-speed transfers creates a flood of timeout calls which significantly slows large transfers and increases CPU usage. Fixed in https://github.com/curl/curl/commit/cacdc27f52 --- src/XrdTpc/XrdTpcState.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/XrdTpc/XrdTpcState.cc b/src/XrdTpc/XrdTpcState.cc index 7d7ed5cc0c2..22b0cd86ba4 100644 --- a/src/XrdTpc/XrdTpcState.cc +++ b/src/XrdTpc/XrdTpcState.cc @@ -70,10 +70,15 @@ bool State::InstallHandlers(CURL *curl) { } curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - // Require a minimum speed from the transfer: must move at least 1MB every 2 minutes - // (roughly 8KB/s). - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 2*60); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1024*1024); + // Only use low-speed limits with libcurl v7.38 or later. + // Older versions have poor transfer performance, corrected in curl commit cacdc27f. + curl_version_info_data *curl_ver = curl_version_info(CURLVERSION_NOW); + if (curl_ver->age > 0 && curl_ver->version_num >= 0x072600) { + // Require a minimum speed from the transfer: must move at least 1MB every 2 minutes + // (roughly 8KB/s). + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 2*60); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1024*1024); + } return true; }