or gigabytes (1024*1024 bytes in a megabyte).
.TP
.B msg\-cache\-slabs: \fI<number>
-Number of slabs in the message cache. Slabs reduce lock contention by threads.
-Must be set to a power of 2. Setting (close) to the number of cpus is a
-reasonable guess.
+Number of slabs in the message cache.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP
.B num\-queries\-per\-thread: \fI<number>
The number of queries that every thread will service simultaneously.
or gigabytes (1024*1024 bytes in a megabyte).
.TP
.B rrset\-cache\-slabs: \fI<number>
-Number of slabs in the RRset cache. Slabs reduce lock contention by threads.
+Number of slabs in the RRset cache.
+Slabs reduce lock contention by threads.
Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP
.B cache\-max\-ttl: \fI<seconds>
Time to live maximum for RRsets and messages in the cache. Default is
roundtrip timing, lameness and EDNS support information. Default is 900.
.TP
.B infra\-cache\-slabs: \fI<number>
-Number of slabs in the infrastructure cache. Slabs reduce lock contention
-by threads. Must be set to a power of 2.
+Number of slabs in the infrastructure cache.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP
.B infra\-cache\-numhosts: \fI<number>
Number of hosts for which information is cached. Default is 10000.
or gigabytes (1024*1024 bytes in a megabyte).
.TP
.B key\-cache\-slabs: \fI<number>
-Number of slabs in the key cache. Slabs reduce lock contention by threads.
-Must be set to a power of 2. Setting (close) to the number of cpus is a
-reasonable guess.
+Number of slabs in the key cache.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP
.B neg\-cache\-size: \fI<number>
Number of bytes size of the aggressive negative cache. Default is 1 megabyte.
not need to be large.
.TP 5
.B ratelimit\-slabs: \fI<number>
-Give power of 2 number of slabs, this is used to reduce lock contention
-in the ratelimit tracking data structure. Close to the number of cpus is
-a fairly good setting.
+Number of slabs in the ratelimit tracking data structure.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP 5
.B ratelimit\-factor: \fI<number>
Set the amount of queries to rate limit when the limit is exceeded.
not need to be large.
.TP 5
.B ip\-ratelimit\-slabs: \fI<number>
-Give power of 2 number of slabs, this is used to reduce lock contention
-in the ip ratelimit tracking data structure. Close to the number of cpus is
-a fairly good setting.
+Number of slabs in the ip ratelimit tracking data structure.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP 5
.B ip\-ratelimit\-factor: \fI<number>
Set the amount of queries to rate limit when the limit is exceeded.
using the same public key. It saves a substantial amount of CPU.
.TP
.B dnscrypt\-shared\-secret\-cache\-slabs: \fI<number>
-Give power of 2 number of slabs, this is used to reduce lock contention
-in the dnscrypt shared secrets cache. Close to the number of cpus is
-a fairly good setting.
+Number of slabs in the dnscrypt shared secrets cache.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.TP
.B dnscrypt\-nonce\-cache\-size: \fI<memory size>
Give the size of the data structure in which the client nonces are kept in.
should be unique for any pair of client pk/server sk.
.TP
.B dnscrypt\-nonce\-cache\-slabs: \fI<number>
-Give power of 2 number of slabs, this is used to reduce lock contention
-in the dnscrypt nonce cache. Close to the number of cpus is
-a fairly good setting.
+Number of slabs in the dnscrypt nonce cache.
+Slabs reduce lock contention by threads.
+Must be set to a power of 2.
+Setting (close) to the number of cpus is a fairly good setting.
+If left unconfigured, it will be configured automatically to be a power of 2
+close to the number of configured threads in multi-threaded environments.
.SS "EDNS Client Subnet Module Options"
.LP
The ECS module must be configured in the \fBmodule\-config:\fR directive e.g.,
cfg->edns_buffer_size = 1232; /* from DNS flagday recommendation */
cfg->msg_buffer_size = 65552; /* 64 k + a small margin */
cfg->msg_cache_size = 4 * 1024 * 1024;
- cfg->msg_cache_slabs = 4;
+ cfg->msg_cache_slabs = 0;
cfg->jostle_time = 200;
cfg->rrset_cache_size = 4 * 1024 * 1024;
- cfg->rrset_cache_slabs = 4;
+ cfg->rrset_cache_slabs = 0;
cfg->host_ttl = 900;
cfg->bogus_ttl = 60;
cfg->min_ttl = 0;
cfg->prefetch = 0;
cfg->prefetch_key = 0;
cfg->deny_any = 0;
- cfg->infra_cache_slabs = 4;
+ cfg->infra_cache_slabs = 0;
cfg->infra_cache_numhosts = 10000;
cfg->infra_cache_min_rtt = 50;
cfg->infra_cache_max_rtt = 120000;
cfg->keep_missing = 366*24*3600; /* one year plus a little leeway */
cfg->permit_small_holddown = 0;
cfg->key_cache_size = 4 * 1024 * 1024;
- cfg->key_cache_slabs = 4;
+ cfg->key_cache_slabs = 0;
cfg->neg_cache_size = 1 * 1024 * 1024;
cfg->local_zones = NULL;
cfg->local_zones_nodefault = NULL;
cfg->ip_ratelimit_cookie = 0;
cfg->ip_ratelimit = 0;
cfg->ratelimit = 0;
- cfg->ip_ratelimit_slabs = 4;
- cfg->ratelimit_slabs = 4;
+ cfg->ip_ratelimit_slabs = 0;
+ cfg->ratelimit_slabs = 0;
cfg->ip_ratelimit_size = 4*1024*1024;
cfg->ratelimit_size = 4*1024*1024;
cfg->ratelimit_for_domain = NULL;
cfg->dnscrypt_provider_cert_rotated = NULL;
cfg->dnscrypt_secret_key = NULL;
cfg->dnscrypt_shared_secret_cache_size = 4*1024*1024;
- cfg->dnscrypt_shared_secret_cache_slabs = 4;
+ cfg->dnscrypt_shared_secret_cache_slabs = 0;
cfg->dnscrypt_nonce_cache_size = 4*1024*1024;
- cfg->dnscrypt_nonce_cache_slabs = 4;
+ cfg->dnscrypt_nonce_cache_slabs = 0;
cfg->pad_responses = 1;
cfg->pad_responses_block_size = 468; /* from RFC8467 */
cfg->pad_queries = 1;
cfg->val_log_squelch = 1;
cfg->minimal_responses = 0;
cfg->harden_short_bufsize = 1;
+ /* Need to explicitly define the slabs from their 0 default value */
+ cfg->ip_ratelimit_slabs = 1;
+ cfg->ratelimit_slabs = 1;
+ cfg->dnscrypt_shared_secret_cache_slabs = 1;
+ cfg->dnscrypt_nonce_cache_slabs = 1;
return cfg;
}
init_cfg_parse();
}
+void
+config_auto_slab_values(struct config_file* cfg)
+{
+#define SET_AUTO_SLAB(var, name, val) \
+do { \
+ if(cfg->var == 0) { \
+ cfg->var = val; \
+ verbose(VERB_QUERY, "setting "name": %lu", (unsigned long)val); \
+ } \
+} while(0);
+#ifdef THREADS_DISABLED
+ size_t pow_2_threads = 1;
+#else
+ size_t pow_2_threads = 4; /* pow2 start */
+ while (pow_2_threads < (size_t)(cfg->num_threads?cfg->num_threads:1) &&
+ /* 1/3 of the distance to the next pow2 value stays with the
+ * lower value */
+ (size_t)cfg->num_threads > pow_2_threads + (pow_2_threads - 1)/3) {
+ pow_2_threads <<= 1;
+ }
+ log_assert((pow_2_threads & (pow_2_threads - 1)) == 0); /* powerof2? */
+#endif /* THREADS_DISABLED */
+
+ SET_AUTO_SLAB(msg_cache_slabs, "msg-cache-slabs", pow_2_threads);
+ SET_AUTO_SLAB(rrset_cache_slabs, "rrset-cache-slabs", pow_2_threads);
+ SET_AUTO_SLAB(infra_cache_slabs, "infra-cache-slabs", pow_2_threads);
+ SET_AUTO_SLAB(key_cache_slabs, "key-cache-slabs", pow_2_threads);
+ SET_AUTO_SLAB(ip_ratelimit_slabs, "ip-ratelimit-slabs", pow_2_threads);
+ SET_AUTO_SLAB(ratelimit_slabs, "ratelimit-slabs", pow_2_threads);
+ SET_AUTO_SLAB(dnscrypt_shared_secret_cache_slabs,
+ "dnscrypt-shared-secret-cache-slabs", pow_2_threads);
+ SET_AUTO_SLAB(dnscrypt_nonce_cache_slabs,
+ "dnscrypt-nonce-cache-slabs", pow_2_threads);
+}
+
int
config_read(struct config_file* cfg, const char* filename, const char* chroot)
{
}
}
globfree(&g);
+ config_auto_slab_values(cfg);
return 1;
}
#endif /* HAVE_GLOB */
return 0;
}
+ config_auto_slab_values(cfg);
return 1;
}