From: Wouter Wijngaards Date: Mon, 3 Sep 2007 10:19:10 +0000 (+0000) Subject: lame cache in bytes. X-Git-Tag: release-0.5~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81fe98956c11247ca852e104b738132a9475827b;p=thirdparty%2Funbound.git lame cache in bytes. git-svn-id: file:///svn/unbound/trunk@579 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index dde5d062a..d608f848c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -6,6 +6,8 @@ - timeout on tcp does not lead to spurious leakage detect. - account memory for name of lame zones, so that memory leakages does not show lame cache growth as a leakage growth. + - config setting for lameness cache expressed in bytes, instead of + number of entries. 31 August 2007: Wouter - can read bind trusted-keys { ... }; files, in a compatibility mode. diff --git a/doc/example.conf b/doc/example.conf index 387b93bd4..c8026a190 100644 --- a/doc/example.conf +++ b/doc/example.conf @@ -85,8 +85,8 @@ server: # the maximum number of hosts that are cached (roundtrip times, EDNS). # infra-cache-numhosts: 10000 - # the maximum number of lame zones per host that are cached. - # infra-cache-numlame: 1000 + # the maximum size of the lame zones cached per host. in bytes. + # infra-cache-lame-size: 10240 # Enable IPv4, "yes" or "no". # do-ip4: yes diff --git a/doc/unbound.conf.5 b/doc/unbound.conf.5 index 9062c1b24..d8fddc3ee 100644 --- a/doc/unbound.conf.5 +++ b/doc/unbound.conf.5 @@ -123,8 +123,10 @@ Number of slabs in the infrastructure cache. Slabs reduce lock contention by threads. Must be set to a power of 2. .It \fBinfra-cache-numhosts:\fR Number of hosts for which information is cached. Default is 10000. -.It \fBinfra-cache-numlame:\fR -Number of zones per host for which lameness is cached. Default is 1000. +.It \fBinfra-cache-lame-size:\fR +Number of bytes that the lameness cache per host is allowed to use. Default +is 10 kb, which gives maximum storage for a couple score zones, depending on +the lame zone name lengths. .It \fBdo-ip4:\fR Enable or disable whether ip4 queries are answered. Default is yes. .It \fBdo-ip6:\fR diff --git a/services/cache/infra.c b/services/cache/infra.c index b9ba761db..c1dc27ced 100644 --- a/services/cache/infra.c +++ b/services/cache/infra.c @@ -105,7 +105,7 @@ infra_create(struct config_file* cfg) } infra->host_ttl = cfg->host_ttl; infra->lame_ttl = cfg->lame_ttl; - infra->max_lame = cfg->infra_cache_numlame; + infra->max_lame_size = cfg->infra_cache_lame_size; return infra; } @@ -126,7 +126,7 @@ infra_adjust(struct infra_cache* infra, struct config_file* cfg) return infra_create(cfg); infra->host_ttl = cfg->host_ttl; infra->lame_ttl = cfg->lame_ttl; - infra->max_lame = cfg->infra_cache_numlame; + infra->max_lame_size = cfg->infra_cache_lame_size; maxmem = cfg->infra_cache_numhosts * (sizeof(struct infra_host_key)+sizeof(struct infra_host_data)); if(maxmem != slabhash_get_size(infra->hosts) || @@ -388,8 +388,7 @@ infra_set_lame(struct infra_cache* infra, if(!data->lameness) { /* create hash table if not there already */ data->lameness = lruhash_create(INFRA_LAME_STARTSIZE, - infra->max_lame*(sizeof(struct infra_lame_key)+ - sizeof(struct infra_lame_data)), infra_lame_sizefunc, + infra->max_lame_size, infra_lame_sizefunc, infra_lame_compfunc, infra_lame_delkeyfunc, infra_lame_deldatafunc, NULL); if(!data->lameness) { diff --git a/services/cache/infra.h b/services/cache/infra.h index 4a0b36d42..d38f0ef78 100644 --- a/services/cache/infra.h +++ b/services/cache/infra.h @@ -103,8 +103,8 @@ struct infra_cache { int host_ttl; /** TTL for Lameness information, in seconds */ int lame_ttl; - /** infra lame cache max memory per host, for this many entries */ - size_t max_lame; + /** infra lame cache max memory per host, in bytes */ + size_t max_lame_size; }; /** infra host cache default hash lookup size */ diff --git a/util/config_file.c b/util/config_file.c index e419ff3fb..a3c82b2b8 100644 --- a/util/config_file.c +++ b/util/config_file.c @@ -90,7 +90,7 @@ config_create() cfg->bogus_ttl = 900; cfg->infra_cache_slabs = 4; cfg->infra_cache_numhosts = 10000; - cfg->infra_cache_numlame = 1000; + cfg->infra_cache_lame_size = 10240; /* easily 40 or more entries */ if(!(cfg->username = strdup(""))) goto error_exit; if(!(cfg->chrootdir = strdup(""))) goto error_exit; if(!(cfg->directory = strdup("/etc/unbound"))) goto error_exit; diff --git a/util/config_file.h b/util/config_file.h index 69f41c27b..171e4b0dc 100644 --- a/util/config_file.h +++ b/util/config_file.h @@ -95,8 +95,8 @@ struct config_file { size_t infra_cache_slabs; /** max number of hosts in the infra cache */ size_t infra_cache_numhosts; - /** max number of lame zones per host in the infra cache */ - size_t infra_cache_numlame; + /** max size of lame zones per host in the infra cache */ + size_t infra_cache_lame_size; /** the target fetch policy for the iterator */ char* target_fetch_policy; diff --git a/util/configlexer.lex b/util/configlexer.lex index e7cdd8370..a086cabcf 100644 --- a/util/configlexer.lex +++ b/util/configlexer.lex @@ -125,7 +125,7 @@ infra-host-ttl{COLON} { YDOUT; return VAR_INFRA_HOST_TTL;} infra-lame-ttl{COLON} { YDOUT; return VAR_INFRA_LAME_TTL;} infra-cache-slabs{COLON} { YDOUT; return VAR_INFRA_CACHE_SLABS;} infra-cache-numhosts{COLON} { YDOUT; return VAR_INFRA_CACHE_NUMHOSTS;} -infra-cache-numlame{COLON} { YDOUT; return VAR_INFRA_CACHE_NUMLAME;} +infra-cache-lame-size{COLON} { YDOUT; return VAR_INFRA_CACHE_LAME_SIZE;} num-queries-per-thread{COLON} { YDOUT; return VAR_NUM_QUERIES_PER_THREAD;} target-fetch-policy{COLON} { YDOUT; return VAR_TARGET_FETCH_POLICY;} harden-short-bufsize{COLON} { YDOUT; return VAR_HARDEN_SHORT_BUFSIZE;} diff --git a/util/configparser.y b/util/configparser.y index ac9fb58dd..ece4e4dcb 100644 --- a/util/configparser.y +++ b/util/configparser.y @@ -74,7 +74,7 @@ extern struct config_parser_state* cfg_parser; %token VAR_MSG_CACHE_SIZE VAR_MSG_CACHE_SLABS VAR_NUM_QUERIES_PER_THREAD %token VAR_RRSET_CACHE_SIZE VAR_RRSET_CACHE_SLABS VAR_OUTGOING_NUM_TCP %token VAR_INFRA_HOST_TTL VAR_INFRA_LAME_TTL VAR_INFRA_CACHE_SLABS -%token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_NUMLAME VAR_NAME +%token VAR_INFRA_CACHE_NUMHOSTS VAR_INFRA_CACHE_LAME_SIZE VAR_NAME %token VAR_STUB_ZONE VAR_STUB_HOST VAR_STUB_ADDR VAR_TARGET_FETCH_POLICY %token VAR_HARDEN_SHORT_BUFSIZE VAR_HARDEN_LARGE_QUERIES %token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR @@ -112,7 +112,7 @@ content_server: server_num_threads | server_verbosity | server_port | server_rrset_cache_slabs | server_outgoing_num_tcp | server_infra_host_ttl | server_infra_lame_ttl | server_infra_cache_slabs | server_infra_cache_numhosts | - server_infra_cache_numlame | server_target_fetch_policy | + server_infra_cache_lame_size | server_target_fetch_policy | server_harden_short_bufsize | server_harden_large_queries | server_do_not_query_address | server_hide_identity | server_hide_version | server_identity | server_version | @@ -448,12 +448,12 @@ server_infra_cache_numhosts: VAR_INFRA_CACHE_NUMHOSTS STRING free($2); } ; -server_infra_cache_numlame: VAR_INFRA_CACHE_NUMLAME STRING +server_infra_cache_lame_size: VAR_INFRA_CACHE_LAME_SIZE STRING { - OUTYY(("P(server_infra_cache_numlame:%s)\n", $2)); + OUTYY(("P(server_infra_cache_lame_size:%s)\n", $2)); if(atoi($2) == 0) yyerror("number expected"); - else cfg_parser->cfg->infra_cache_numlame = atoi($2); + else cfg_parser->cfg->infra_cache_lame_size = atoi($2); free($2); } ;