]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
lame cache in bytes.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 3 Sep 2007 10:19:10 +0000 (10:19 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 3 Sep 2007 10:19:10 +0000 (10:19 +0000)
git-svn-id: file:///svn/unbound/trunk@579 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
doc/example.conf
doc/unbound.conf.5
services/cache/infra.c
services/cache/infra.h
util/config_file.c
util/config_file.h
util/configlexer.lex
util/configparser.y

index dde5d062a216f79e094415469639f63796180c1d..d608f848c2de7db34a442be1cafdcfe3d22cbf1b 100644 (file)
@@ -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. 
index 387b93bd49a4c9121b293d2cd057026cd320a697..c8026a190bbfdd53eb640853059ea71adb76ee22 100644 (file)
@@ -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
index 9062c1b246035432d7ee1b92de35f223fad4a8c1..d8fddc3eef29ea48788dfea3535961ecb88a559a 100644 (file)
@@ -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>
 Number of hosts for which information is cached. Default is 10000.
-.It \fBinfra-cache-numlame:\fR <number>
-Number of zones per host for which lameness is cached. Default is 1000.
+.It \fBinfra-cache-lame-size:\fR <number>
+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 <yes or no>
 Enable or disable whether ip4 queries are answered. Default is yes.
 .It \fBdo-ip6:\fR <yes or no>
index b9ba761dbb5190d97e34d9397ce940f4792e684b..c1dc27ced22dd2aad998a62cad8406b8dbfff2b2 100644 (file)
@@ -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) {
index 4a0b36d42b2569a7e6328d17a815f4f7e65be129..d38f0ef78eac474bd4748a08b360767c72be0d5e 100644 (file)
@@ -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 */
index e419ff3fb1eaacb38ca6fc41e5a3edb5e74b29a6..a3c82b2b868216d665886ec837be094cf9e269a5 100644 (file)
@@ -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;
index 69f41c27b3a1601ef061e420570f5aa4e2247401..171e4b0dc83e9542dd87edfc5e973c4151a17701 100644 (file)
@@ -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;
index e7cdd83701c5f2ef7db2f6a647548c4834158682..a086cabcfea7cd47f6254cb18f1eec31c4f07ebb 100644 (file)
@@ -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;}
index ac9fb58dda6e1a3fcc11587559a15714bcbfd6b0..ece4e4dcbc9a6655ac996281605dd58074ac61c9 100644 (file)
@@ -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);
        }
        ;