On Mon, 14 Feb 2022, Henrik Holst wrote:
So first ".curlrc" is strlen:ed and then 7 calls to alloc_addbyter() which
is the exact length of ".curlrc" so it looks like some function goes over
strings one byte at a time and adds them to a dynamic buffer one by one.
Perhaps this is done to
Those single byte memcpy() comes from alloc_addbyter() which in turn is
called by Curl_dyn_vprintf() and curl_mvaprintf() and I can see from traces
that they are e.g called like this:
0.180 us [ 66160] | strlen(".curlrc") = 7;
[ 66160] |
Den mån 14 feb. 2022 kl 09:11 skrev Daniel Stenberg via curl-library <
curl-library@lists.haxx.se>:
> On Thu, 10 Feb 2022, Daniel Stenberg via curl-library wrote:
>
> > In 7.81.0 this made 596 to 600 strlen() calls.
> >
> > In git master, this now makes 390 to 392 calls. A 33% reduction.
>
>
free() seems odd. Since they vastly outnumber (malloc+calloc+realloc),
likely many (most?) are free(NULL) -- e.g. clean up paths where
something might have been allocated.
If this is the case, they're relatively cheap - the call overhead + an
early check for NULL arg.
The 1 byte memcpy is
Just a rough estimate: do you free() 2.5 times on average?
> Am 14.02.2022 um 09:33 schrieb Daniel Stenberg via curl-library
> :
>
> Other fun observations running this same command line:
>
> The top-25 lib calls done:
>
> 2239 free
>635 malloc
>545 memcpy
>300 memchr
>245
Other fun observations running this same command line:
The top-25 lib calls done:
2239 free
635 malloc
545 memcpy
300 memchr
245 strcmp
225 strlen
162 inet_pton
134 clock_gettime
110 OPENSSL_sk_value
110 ASN1_STRING_length
110 ASN1_STRING_get0_data
On Thu, 10 Feb 2022, Daniel Stenberg via curl-library wrote:
In 7.81.0 this made 596 to 600 strlen() calls.
In git master, this now makes 390 to 392 calls. A 33% reduction.
After some more cleaning up by Henrik:
223 to 225 calls. A 62% reduction from 7.81.0!
--
/ daniel.haxx.se
|
Hello,
In a previous mail here [1], I counted strlens done by curl. This then
triggered some work, mostly by Henrik Holst, to update code to not use
strlen() unnecessarily when it can avoid it.
I did a quick follow-up count today. I don't recall the exact build options I
used the last time,