aboutsummaryrefslogtreecommitdiffstats
path: root/config/unbound/unbound.inc
diff options
context:
space:
mode:
authorWarren Baker <warren@decoy.co.za>2013-06-13 20:12:22 +0200
committerWarren Baker <warren@decoy.co.za>2013-06-13 20:12:22 +0200
commit4431280099dae7401d5b570a9dfe7ab574e0d2df (patch)
tree3450636c426ecdf385888ab38e39f7e57f74545e /config/unbound/unbound.inc
parent6751b1db500c831eac7968a4cdd748b9cbc07949 (diff)
downloadpfsense-packages-4431280099dae7401d5b570a9dfe7ab574e0d2df.tar.gz
pfsense-packages-4431280099dae7401d5b570a9dfe7ab574e0d2df.tar.bz2
pfsense-packages-4431280099dae7401d5b570a9dfe7ab574e0d2df.zip
Work out the recommended *-slabs setting dynamically. Kudos to Reiner030 on the forum
Diffstat (limited to 'config/unbound/unbound.inc')
-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'])) {