cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl and Perl's WWW::Curl::Easy slower than LWP on small HTTP POSTs

From: Martin J. Evans <martin.evans_at_easysoft.com>
Date: Wed, 14 Sep 2011 11:16:38 +0100

On 14/09/11 11:10, Tim Bannister wrote:
> On 14 Sep 2011, at 10:44, Martin J. Evans wrote:
>
>> Through experimentation I have discovered setting either CURLOPT_TCP_NODELAY or CURLOPT_FORBID_REUSE speeds up the POSTs so Curl is faster than LWP. I was a little surprised setting CURLOPT_TCP_NOLDELAY made a difference but as it does it sort of suggested to me that maybe the POST headers are sent first then followed up by the form data (i.e., at least 2 writes to the socket). Also, if CURLOPT_FORBID_REUSE is set I suppose it is possible libcurl does a shutdown(write) on the socket after the last write which would also expedite any unset data.
>
> Unless TCP_NODELAY is set, the OS kernel is likely to delay sending the packets for a short while, to see if any more turn up. Closing the socket would flush the kernel's TCP buffers and shortcut the Nagle delay.
>
> It's likely that you'll see different behaviours with a different OS / kernel.

Thanks Tim.

However, the socket cannot be closed before the read to get the response occurs. It could call shutdown(write) but I cannot see that in the strace output. So I still don't get why disabling reuse makes a difference.

BTW this was on Linux Ubuntu 10.10 maverick and with libcurl 7.19.5 although I also tried 7.21.7.

Martin

-- 
Martin J. Evans
Easysoft Limited
http://www.easysoft.com
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-14