diff options
author | Daniel Stenberg <daniel@haxx.se> | 2022-08-27 14:48:13 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-08-29 00:07:09 +0200 |
commit | 7632c0d25ad797a8f17ff071f3c4e9fe8a73a398 (patch) | |
tree | d30ac143495d0cde06fd12f6cd5f2f9a0a53a3ff /lib/multi.c | |
parent | c5c6e86783d6e2caea50eee66a29c7157c92f54f (diff) | |
download | curl-7632c0d25ad797a8f17ff071f3c4e9fe8a73a398.tar.gz |
multi: use larger dns hash table for multi interface
Have curl_multi_init() use a much larger DNS hash table than used for
the easy interface to scale and perform better when used with _many_
host names.
curl_share_init() sets an in-between size.
Inspired-by: Ivan Tsybulin
See #9340
Closes #9376
Diffstat (limited to 'lib/multi.c')
-rw-r--r-- | lib/multi.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/multi.c b/lib/multi.c index ac753d212..5340a0c8a 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -84,6 +84,10 @@ #define CURL_CONNECTION_HASH_SIZE 97 #endif +#ifndef CURL_DNS_HASH_SIZE +#define CURL_DNS_HASH_SIZE 71 +#endif + #define CURL_MULTI_HANDLE 0x000bab1e #define GOOD_MULTI_HANDLE(x) \ @@ -388,7 +392,8 @@ static CURLMcode multi_addmsg(struct Curl_multi *multi, } struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ - int chashsize) /* connection hash */ + int chashsize, /* connection hash */ + int dnssize) /* dns hash */ { struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi)); @@ -397,7 +402,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ multi->magic = CURL_MULTI_HANDLE; - Curl_init_dnscache(&multi->hostcache); + Curl_init_dnscache(&multi->hostcache, dnssize); sh_init(&multi->sockhash, hashsize); @@ -451,7 +456,8 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */ struct Curl_multi *curl_multi_init(void) { return Curl_multi_handle(CURL_SOCKET_HASH_TABLE_SIZE, - CURL_CONNECTION_HASH_SIZE); + CURL_CONNECTION_HASH_SIZE, + CURL_DNS_HASH_SIZE); } CURLMcode curl_multi_add_handle(struct Curl_multi *multi, |