curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Fewer mallocs is better, episode #47

From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 26 Jan 2022 10:23:51 +0100 (CET)

Hi,

Just wanted to share this fun fact with you all.

Here's my test command line:

     curl -sL https://google.com -o /dev/null

I ran this command line with 4 recent curl versions and I counted the total
number of allocations (using the script shown below). These are only
allocations done by curl and libcurl code, the dependencies' allocations are
not included.

  * 7.70.0

  Allocations: 415 Maximum allocated: 239432

  * 7.78.0

  Allocations: 391 Maximum allocated: 201926

  * 7.81.0

  Allocations: 391 Maximum allocated: 201700

  * 7.82.0-DEV (as of git master right now)

  Allocations: 174 Maximum allocated: 201684

This is a 55% reduction in number of allocations from 7.81.0 (while
maintaining and even shrinking the max amount a tiny bit)! The bulk of this
improvement comes from this single commit:
https://github.com/curl/curl/commit/955cb99130f7c

The test script, requires a curl built debug-enabled:

#!/bin/sh
export CURL_MEMDEBUG=$HOME/tmp/curlmem.log
./src/curl -sL https://google.com -o /dev/null
./tests/memanalyze.pl -v $HOME/tmp/curlmem.log

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-01-26