Commit 96ece5c0 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

curl: set a 100K buffer size by default

Test command 'time curl http://localhost/80GB -so /dev/null' on a Debian
Linux.

Before (middle performing run out 9):

 real    0m28.078s
 user    0m11.240s
 sys     0m12.876s

After (middle performing run out 9)

 real    0m26.356s (93.9%)
 user    0m5.324s  (47.4%)
 sys     0m8.368s  (65.0%)

Also, doing SFTP over a 200 millsecond latency link is now about 6 times
faster.

Closes #1446
parent e698b822
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -246,6 +246,8 @@ static void setfiletime(long filetime, const char *filename,
#endif /* defined(HAVE_UTIME) || \
#endif /* defined(HAVE_UTIME) || \
          (defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T >= 8)) */
          (defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T >= 8)) */


#define BUFFER_SIZE (100*1024)

static CURLcode operate_do(struct GlobalConfig *global,
static CURLcode operate_do(struct GlobalConfig *global,
                           struct OperationConfig *config)
                           struct OperationConfig *config)
{
{
@@ -888,10 +890,12 @@ static CURLcode operate_do(struct GlobalConfig *global,
        my_setopt(curl, CURLOPT_SEEKDATA, &input);
        my_setopt(curl, CURLOPT_SEEKDATA, &input);
        my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);
        my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);


        if(config->recvpersecond)
        if(config->recvpersecond &&
          /* tell libcurl to use a smaller sized buffer as it allows us to
           (config->recvpersecond < BUFFER_SIZE))
             make better sleeps! 7.9.9 stuff! */
          /* use a smaller sized buffer for better sleeps */
          my_setopt(curl, CURLOPT_BUFFERSIZE, (long)config->recvpersecond);
          my_setopt(curl, CURLOPT_BUFFERSIZE, (long)config->recvpersecond);
        else
          my_setopt(curl, CURLOPT_BUFFERSIZE, (long)BUFFER_SIZE);


        /* size of uploaded file: */
        /* size of uploaded file: */
        if(uploadfilesize != -1)
        if(uploadfilesize != -1)
+1 −0
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ int main(int argc, char *argv[])
  CURL *hnd;
  CURL *hnd;


  hnd = curl_easy_init();
  hnd = curl_easy_init();
  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1400");
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1400");
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
+1 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,7 @@ int main(int argc, char *argv[])
  slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
  slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");


  hnd = curl_easy_init();
  hnd = curl_easy_init();
  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1401");
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1401");
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
  curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
+1 −0
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ int main(int argc, char *argv[])
  CURL *hnd;
  CURL *hnd;


  hnd = curl_easy_init();
  hnd = curl_easy_init();
  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1402");
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1402");
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
+1 −0
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
  CURL *hnd;
  CURL *hnd;


  hnd = curl_easy_init();
  hnd = curl_easy_init();
  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1403?foo=bar&baz=quux");
  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1403?foo=bar&baz=quux");
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
Loading