]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
memory footprint improvements.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 27 Nov 2007 15:52:41 +0000 (15:52 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 27 Nov 2007 15:52:41 +0000 (15:52 +0000)
git-svn-id: file:///svn/unbound/trunk@778 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/cache/dns.h
testcode/memstats.c
util/data/msgparse.h

index 1b0d77004e075a9efa74c8b519bc9f51fc73cda6..834fb9e760ec53ddd6831b3f48fe76b765208308 100644 (file)
@@ -1,5 +1,11 @@
 27 November 2007: Wouter
        - per suggestion in rfc2308, replaced default max-ttl value with 1 day.
+       - set size of msgparse lookup table to 32, from 1024, so that its size
+         is below the 2048 regional large size threshold, and does not cause
+         a call to malloc when a message is parsed.
+       - update of memstats tool to print number of allocation calls.
+         This is what is taking time (not space) and indicates the avg size
+         of the allocations as well. region_alloc stat is removed.
 
 22 November 2007: Wouter
        - noted EDNS in-the-middle dropping trouble as a TODO.
index 152c44ad2968a8f7905d9185691da15d2c9b4e8b..6d16022f238aa0be3af1c7f96bbbd9d4419b9933 100644 (file)
@@ -137,6 +137,4 @@ struct dns_msg* dns_cache_lookup(struct module_env* env,
 int cache_fill_missing(struct module_env* env, uint16_t qclass, 
        struct regional* region, struct delegpt* dp);
 
-/** Find covering DNAME */
-
 #endif /* SERVICES_CACHE_DNS_H */
index 369dc59ce6739281a602ddf7e8ce8115205c2d91..bf48d7f7153ea991126047b6b7a7aef4252fe245 100644 (file)
@@ -60,14 +60,8 @@ struct codeline {
        uint64_t alloc;
        /** number of bytes freed */
        uint64_t free;
-};
-
-/**
- * Other allocation stats
- */
-struct alloc_misc {
-       /** number of region allocs */
-       uint64_t region_alloc;
+       /** number allocations and frees */
+       uint64_t calls;
 };
 
 /** print usage and exit */
@@ -101,18 +95,6 @@ match(char* line)
        return 0;
 }
 
-/** read up the region stats */
-static void
-read_region_stat(char* line, struct alloc_misc* misc)
-{
-       long num = 0;
-       if(sscanf(line+50, "%ld", &num) != 1) {
-               printf("%s\n%s\n", line, line+50);
-               fatal_exit("unhandled region");
-       }
-       misc->region_alloc += num;
-}
-
 /** find or alloc codeline in tree */
 static struct codeline*
 get_codeline(rbtree_t* tree, char* key, char* func)
@@ -153,6 +135,7 @@ read_malloc_stat(char* line, rbtree_t* tree)
        if(!cl)
                fatal_exit("alloc failure");
        cl->alloc += num;
+       cl->calls ++;
 }
 
 /** read up the calloc stats */
@@ -177,6 +160,7 @@ read_calloc_stat(char* line, rbtree_t* tree)
        if(!cl)
                fatal_exit("alloc failure");
        cl->alloc += num*sz;
+       cl->calls ++;
 }
 
 /** get size of file */
@@ -192,7 +176,7 @@ get_file_size(const char* fname)
 
 /** read the logfile */
 static void
-readfile(rbtree_t* tree, const char* fname, struct alloc_misc* misc)
+readfile(rbtree_t* tree, const char* fname)
 {
        off_t total = get_file_size(fname);
        off_t done = (off_t)0;
@@ -213,8 +197,6 @@ readfile(rbtree_t* tree, const char* fname, struct alloc_misc* misc)
 
                if(!match(buf))
                        continue;
-               if(strncmp(buf+36, "region ", 7) == 0)
-                       read_region_stat(buf, misc);
                else if(strstr(buf+36, "malloc("))
                        read_malloc_stat(buf, tree);
                else if(strstr(buf+36, "calloc("))
@@ -230,20 +212,19 @@ readfile(rbtree_t* tree, const char* fname, struct alloc_misc* misc)
 
 /** print memory stats */
 static void
-printstats(rbtree_t* tree, struct alloc_misc* misc)
+printstats(rbtree_t* tree)
 {
        struct codeline* cl;
-       uint64_t total = 0;
-       printf("%12lld in region alloc\n", (long long)misc->region_alloc);
-       total += misc->region_alloc;
+       uint64_t total = 0, tcalls = 0;
        RBTREE_FOR(cl, struct codeline*, tree) {
-               printf("%12lld in %s %s\n", (long long)cl->alloc, 
-                       cl->codeline, cl->func);
+               printf("%12lld / %8lld in %s %s\n", (long long)cl->alloc, 
+                       (long long)cl->calls, cl->codeline, cl->func);
                total += cl->alloc;
+               tcalls += cl->calls;
        }
        printf("------------\n");
-       printf("%12lld total in %ld code lines\n", (long long)total, 
-               (long)tree->count);
+       printf("%12lld / %8lld total in %ld code lines\n", (long long)total, 
+               (long long)tcalls, (long)tree->count);
        printf("\n");
 }
 
@@ -251,15 +232,13 @@ printstats(rbtree_t* tree, struct alloc_misc* misc)
 int main(int argc, const char* argv[])
 {
        rbtree_t* tree = 0;
-       struct alloc_misc misc;
        if(argc != 2) {
                usage();
        }
        tree = rbtree_create(codeline_cmp);
        if(!tree)
                fatal_exit("alloc failure");
-       memset(&misc, 0, sizeof(misc));
-       readfile(tree, argv[1], &misc);
-       printstats(tree, &misc);
+       readfile(tree, argv[1]);
+       printstats(tree);
        return 0;
 }
index c5e2588740f0ab086d742cdc7fb23c9396ebe70a..ea21a42693892383cb5181ba7084cd5ce8c19bf1 100644 (file)
@@ -68,7 +68,7 @@ struct rr_parse;
 struct regional;
 
 /** number of buckets in parse rrset hash table. Must be power of 2. */
-#define PARSE_TABLE_SIZE 1024
+#define PARSE_TABLE_SIZE 32
 /** Maximum TTL that is allowed. */
 extern uint32_t MAX_TTL;
 /** Negative cache time (for entries without any RRs.) */