curl / Mailing Lists / curl-library / Single Mail

curl-library

DNS Lookup time (CURLINFO_NAMELOOKUP_TIME) performs worse than getaddrinfo()

From: Bernhard Jaeger <B.Jaeger1_at_gmx.net>
Date: Wed, 20 Jun 2018 19:52:28 +0200
Hello,
 
I am currently using libcurl (C version) to measure TCP/TLS and DNS lookup times of a connection using the curl_easy_getinfo interface.
I also have another program where I do DNS lookup via getaddrinfo(). I measure the time the DNS lookup takes by measuring the time getaddrinfo() needs to return.
Now the thing that bothers me is when I run both programms I get different results for the DNS lookup time with libcurl performing consistently worse than the other program.
The same thing appears in both a Windows and Linux environment, doesn't depend on the order the programs are called in (so I assume caching is not the problem here) and is consistent over several hundreds of measurements.
For example:
(Windows version with some older version of libcurl)
libcurl DNS lookup time: 16ms
getaddrinfo() DNS lookup time: 6ms
 
(Linux version with libcurl 7.61-Dev, VM with high speed connection)
libcurl DNS lookup time: 4ms
getaddrinfo() DNS lookup time: 1ms
 
I honestly have no Idea where this performance difference comes from as DNS lookup is something the operating system does and should be the same for both programs.
Now libcurl states in the documentation

"NAMELOOKUP: CURLINFO_NAMELOOKUP_TIME and fICURLINFO_NAMELOOKUP_TIME_T. The time it took from the start until the name resolving was completed"

start doesn't necessarily mean start of the DNS lookup. Is there other stuff besides the DNS lookup that also is included in the measured time? (and if so is there a way to exclude it?)
 
Following that I would also be interested to know whether:
"CONNECT: CURLINFO_CONNECT_TIME and CURLINFO_CONNECT_TIME_T. The time it took from the start until the connect to the remote host (or proxy) was completed."
is only the TCP handshake and

"APPCONNECT: CURLINFO_APPCONNECT_TIME and CURLINFO_APPCONNECT_TIME_T. The time it took from the start until the SSL connect/handshake with the remote host was completed. (Added in 7.19.0) The latter is the integer version (measuring microseconds)."

is only the TLS handshake (part) or if there are other things getting measured here.

I hope a developer can answer me these questions.

-- Bernhard Jaeger

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-06-20