aboutsummaryrefslogtreecommitdiffstats
path: root/config/unbound
diff options
context:
space:
mode:
Diffstat (limited to 'config/unbound')
-rw-r--r--config/unbound/unbound.inc22
1 files changed, 9 insertions, 13 deletions
diff --git a/config/unbound/unbound.inc b/config/unbound/unbound.inc
index 156b14fc..8cd186fb 100644
--- a/config/unbound/unbound.inc
+++ b/config/unbound/unbound.inc
@@ -621,23 +621,19 @@ function unbound_optimization() {
// Set the number of threads equal to number of CPUs.
// Use 1 (disable threading) if for some reason this sysctl fails.
$numprocs = intval(trim(`/sbin/sysctl kern.smp.cpus | /usr/bin/cut -d" " -f2`));
- if($numprocs > 0)
+ if($numprocs > 1) {
$optimization['number_threads'] = "num-threads: {$numprocs}";
- else
+ $optimize_num = pow(2,floor(log($numprocs,2)));
+ } else {
$optimization['number_threads'] = "num-threads: 1";
+ $optimize_num = 4;
+ }
// Slabs to help reduce lock contention.
- if ($numprocs > 4) {
- $optimization['msg_cache_slabs'] = "msg-cache-slabs: {$numprocs}";
- $optimization['rrset_cache_slabs'] = "rrset-cache-slabs: {$numprocs}";
- $optimization['infra_cache_slabs'] = "infra-cache-slabs: {$numprocs}";
- $optimization['key_cache_slabs'] = "key-cache-slabs: {$numprocs}";
- } else {
- $optimization['msg_cache_slabs'] = "msg-cache-slabs: 4";
- $optimization['rrset_cache_slabs'] = "rrset-cache-slabs: 4";
- $optimization['infra_cache_slabs'] = "infra-cache-slabs: 4";
- $optimization['key_cache_slabs'] = "key-cache-slabs: 4";
- }
+ $optimization['msg_cache_slabs'] = "msg-cache-slabs: {$optimize_num}";
+ $optimization['rrset_cache_slabs'] = "rrset-cache-slabs: {$optimize_num}";
+ $optimization['infra_cache_slabs'] = "infra-cache-slabs: {$optimize_num}";
+ $optimization['key_cache_slabs'] = "key-cache-slabs: {$optimize_num}";
// Memory usage - default is 4Mb if nothing has been selected
if(isset($unbound_config['msg_cache_size'])) {