]> granicus.if.org Git - curl/commitdiff
curl: set a 100K buffer size by default
authorDaniel Stenberg <daniel@haxx.se>
Mon, 24 Apr 2017 10:03:08 +0000 (12:03 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 25 Apr 2017 09:02:19 +0000 (11:02 +0200)
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

src/tool_operate.c
tests/data/test1400
tests/data/test1401
tests/data/test1402
tests/data/test1403
tests/data/test1404
tests/data/test1405
tests/data/test1406
tests/data/test1407
tests/data/test1420

index 0e84ac398024fddd7497764633df3e708eb3f9c1..724826c8e338d2161b21466505217567e251e9ed 100644 (file)
@@ -246,6 +246,8 @@ static void setfiletime(long filetime, const char *filename,
 #endif /* defined(HAVE_UTIME) || \
           (defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T >= 8)) */
 
+#define BUFFER_SIZE (100*1024)
+
 static CURLcode operate_do(struct GlobalConfig *global,
                            struct OperationConfig *config)
 {
@@ -888,10 +890,12 @@ static CURLcode operate_do(struct GlobalConfig *global,
         my_setopt(curl, CURLOPT_SEEKDATA, &input);
         my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);
 
-        if(config->recvpersecond)
-          /* tell libcurl to use a smaller sized buffer as it allows us to
-             make better sleeps! 7.9.9 stuff! */
+        if(config->recvpersecond &&
+           (config->recvpersecond < BUFFER_SIZE))
+          /* use a smaller sized buffer for better sleeps */
           my_setopt(curl, CURLOPT_BUFFERSIZE, (long)config->recvpersecond);
+        else
+          my_setopt(curl, CURLOPT_BUFFERSIZE, (long)BUFFER_SIZE);
 
         /* size of uploaded file: */
         if(uploadfilesize != -1)
index e820843241c61401b7da1d3cf85f6de64f192700..0cef18dfd0c98517cf355a764cdb3e92aa17a760 100644 (file)
@@ -68,6 +68,7 @@ int main(int argc, char *argv[])
   CURL *hnd;
 
   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_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
index 34469a3761e78908b14f0c94adea967aafeaf4c0..d6c904088ee295f82db69b5b922f61bfc0455338 100644 (file)
@@ -80,6 +80,7 @@ int main(int argc, char *argv[])
   slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
 
   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_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
index bf22695e6976b38b4212b93ad07b411d265e4c96..c3581287a0aa2a915726161b317349b1a942c338 100644 (file)
@@ -73,6 +73,7 @@ int main(int argc, char *argv[])
   CURL *hnd;
 
   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_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
index 1a0fc7d8fcd0e9f699c83d524e7941e974ac7d25..3a5b1b236d1031e0376ccf25e305fcdc9d1c21d4 100644 (file)
@@ -70,6 +70,7 @@ int main(int argc, char *argv[])
   CURL *hnd;
 
   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_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
index c0bb81b5805acb2d7a6cac49a61bf0e06197b7a3..c86d2602c2113417cecd724a63698305715f9c4e 100644 (file)
@@ -123,6 +123,7 @@ int main(int argc, char *argv[])
                CURLFORM_END);
 
   hnd = curl_easy_init();
+  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
   curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1404");
   curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_HTTPPOST, post1);
index 041d9f3bdf7280c5dae7601a0f4a5448ebabaeee..f3ad3e7953fda3e2c22332e83285eb8160f56af4 100644 (file)
@@ -83,6 +83,7 @@ int main(int argc, char *argv[])
   slist3 = curl_slist_append(slist3, "*FAIL HARD");
 
   hnd = curl_easy_init();
+  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
   curl_easy_setopt(hnd, CURLOPT_URL, "ftp://%HOSTIP:%FTPPORT/1405");
   curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_QUOTE, slist1);
index 6276b9e97c53b3f012b4ce264d49784b7647f6c1..033957f607687f4a509dbc65fd57c377f0fbf1b6 100644 (file)
@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
   slist1 = curl_slist_append(slist1, "recipient.two@example.com");
 
   hnd = curl_easy_init();
+  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
   curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38);
   curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/1406");
   curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
index 6b44cb79a5597161d1733f48c6f8fe9fc55a2084..5a3de1b179dd510eaae957d911909190add73225 100644 (file)
@@ -57,6 +57,7 @@ int main(int argc, char *argv[])
   CURL *hnd;
 
   hnd = curl_easy_init();
+  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
   curl_easy_setopt(hnd, CURLOPT_URL, "pop3://%HOSTIP:%POP3PORT/1407");
   curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 1L);
index 6183fd659a0462b2219cbcb135d1b2c4d68f60d1..38139e0b0847bf864d57744ba46cef9064a1181f 100644 (file)
@@ -63,6 +63,7 @@ int main(int argc, char *argv[])
   CURL *hnd;
 
   hnd = curl_easy_init();
+  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
   curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/1420/;UID=1");
   curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
   curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret");