]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
damp interations adjustments [RT#15404]
authorMark Andrews <marka@isc.org>
Tue, 20 Sep 2005 04:33:48 +0000 (04:33 +0000)
committerMark Andrews <marka@isc.org>
Tue, 20 Sep 2005 04:33:48 +0000 (04:33 +0000)
lib/dns/cache.c
lib/dns/include/dns/lib.h
lib/dns/masterdump.c
lib/dns/rbtdb.c

index 95e9fcdaee7292e208f1ae9d2772ca0197184aa4..d2a675c90a8a05f38b7b53b966d5f233432e4858 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: cache.c,v 1.57.18.7 2005/09/05 02:30:51 marka Exp $ */
+/* $Id: cache.c,v 1.57.18.8 2005/09/20 04:33:45 marka Exp $ */
 
 /*! \file */
 
@@ -157,6 +157,12 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event);
 static void
 overmem_cleaning_action(isc_task_t *task, isc_event_t *event);
 
+/*%
+ * Work out how many nodes can be cleaned in the time between two
+ * requests to the nameserver.  Smooth the resulting number and use
+ * it as a estimate for the number of nodes to be cleaned in the next
+ * iteration.
+ */
 static void
 adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining,
                 isc_time_t *start)
@@ -169,14 +175,14 @@ adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining,
        unsigned int names;
        
        /*
-        * Tune for minumum of 100 pps.
+        * Tune for minumum of 100 packets per second (pps).
         */
        if (pps < 100)
                pps = 100;
 
        isc_time_now(&end);
 
-       interval = 1000000 / pps;
+       interval = 1000000 / pps; /* Interval between packets in usecs. */
        if (interval == 0)
                interval = 1;
 
@@ -190,14 +196,18 @@ adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining,
                      interval, names, usecs);
        
        if (usecs == 0) {
+               /*
+                * If we cleaned all the nodes in unmeasurable time
+                * double the number of nodes to be cleaned next time.
+                */
                if (names == cleaner->increment) {
                        cleaner->increment *= 2;
                        if (cleaner->increment > DNS_CACHE_CLEANERINCREMENT)
                                cleaner->increment = DNS_CACHE_CLEANERINCREMENT;
                        isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
                                      DNS_LOGMODULE_CACHE, ISC_LOG_INFO,
-                                     "new clear->increment = %d\n",
-                                     cleaner->increment);
+                                     "%p:new clear->increment = %d\n",
+                                     cleaner, cleaner->increment);
                }
                return;
        }
@@ -209,10 +219,14 @@ adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining,
        else if (new > DNS_CACHE_CLEANERINCREMENT)
                new = DNS_CACHE_CLEANERINCREMENT;
 
+       /* Smooth */
+       new = (new + cleaner->increment * 7) / 8;
+
        cleaner->increment = (unsigned int)new;
+
        isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_CACHE,
-                     ISC_LOG_INFO, "new clear->increment = %u\n",
-                     cleaner->increment);
+                     ISC_LOG_INFO, "%p:new clear->increment = %u\n",
+                     cleaner, cleaner->increment);
 }
 
 static inline isc_result_t
index 1d2508e4a92343b6ada315a313004df6f3e8c5b1..d59dde3a447d32ff8318b51ab5be3286292c789c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: lib.h,v 1.8.18.3 2005/08/15 01:46:51 marka Exp $ */
+/* $Id: lib.h,v 1.8.18.4 2005/09/20 04:33:48 marka Exp $ */
 
 #ifndef DNS_LIB_H
 #define DNS_LIB_H 1
@@ -27,6 +27,9 @@
 
 ISC_LANG_BEGINDECLS
 
+/*%
+ * Tuning: external query load in packets per seconds.
+ */
 LIBDNS_EXTERNAL_DATA extern unsigned int dns_pps;
 LIBDNS_EXTERNAL_DATA extern isc_msgcat_t *dns_msgcat;
 
index 13f39c1456ba71c21536a23e5f03eec1a287cf9b..3eca4789c9573fc5804f01da713912affb854450 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: masterdump.c,v 1.73.18.7 2005/09/05 02:30:51 marka Exp $ */
+/* $Id: masterdump.c,v 1.73.18.8 2005/09/20 04:33:46 marka Exp $ */
 
 /*! \file */
 
@@ -1370,8 +1370,14 @@ dumptostreaminc(dns_dumpctx_t *dctx) {
                result = dns_dbiterator_next(dctx->dbiter);
        }
 
+       /*
+        * Work out how many nodes can be written in the time between
+        * two requests to the nameserver.  Smooth the resulting number and
+        * use it as a estimate for the number of nodes to be written in the
+        * next iteration.
+        */
        if (dctx->nodes != 0 && result == ISC_R_SUCCESS) {
-               unsigned int pps = dns_pps;
+               unsigned int pps = dns_pps;     /* packets per second */
                unsigned int interval;
                isc_uint64_t usecs;
                isc_time_t end;
@@ -1379,7 +1385,7 @@ dumptostreaminc(dns_dumpctx_t *dctx) {
                isc_time_now(&end);
                if (pps < 100)
                        pps = 100;
-               interval = 1000000 / pps;
+               interval = 1000000 / pps;       /* interval in usecs */
                if (interval == 0)
                        interval = 1;
                usecs = isc_time_microdiff(&end, &start);
@@ -1388,12 +1394,20 @@ dumptostreaminc(dns_dumpctx_t *dctx) {
                        if (dctx->nodes > 1000)
                                dctx->nodes = 1000;
                } else {
-                       dctx->nodes = dctx->nodes * interval;
-                       dctx->nodes /= (unsigned int)usecs;
-                       if (dctx->nodes == 0)
-                               dctx->nodes = 1;
-                       else if (dctx->nodes > 1000)
-                               dctx->nodes = 1000;
+                       nodes = dctx->nodes * interval;
+                       nodes /= (unsigned int)usecs;
+                       if (nodes == 0)
+                               nodes = 1;
+                       else if (nodes > 1000)
+                               nodes = 1000;
+
+                       /* Smooth and assign. */
+                       dctx->nodes = (nodes + dctx->nodes * 7) / 8;
+
+                       isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL,
+                                     DNS_LOGMODULE_MASTERDUMP, ISC_LOG_INFO,
+                                     "dumptostreaminc(%p) new nodes -> %d\n",
+                                     dctx, dctx->nodes);
                }
                dns_dbiterator_pause(dctx->dbiter);
                result = DNS_R_CONTINUE;
index 301e46b728539e7915ad96db7ace6ebf38195df3..2e049dc91c5d7b7a3a33b4ce77cb9d35b5ac3934 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rbtdb.c,v 1.196.18.18 2005/09/05 02:30:52 marka Exp $ */
+/* $Id: rbtdb.c,v 1.196.18.19 2005/09/20 04:33:46 marka Exp $ */
 
 /*! \file */
 
@@ -551,34 +551,52 @@ free_rbtdb_callback(isc_task_t *task, isc_event_t *event) {
        free_rbtdb(rbtdb, ISC_TRUE, event);
 }
 
+/*%
+ * Work out how many nodes can be deleted in the time between two
+ * requests to the nameserver.  Smooth the resulting number and use it
+ * as a estimate for the number of nodes to be deleted in the next
+ * iteration.
+ */
 static unsigned int
 adjust_quantum(unsigned int old, isc_time_t *start) {
-       unsigned int pps = dns_pps;
+       unsigned int pps = dns_pps;     /* packets per second */
        unsigned int interval;
        isc_uint64_t usecs;
        isc_time_t end;
+       unsigned int new;
 
        if (pps < 100)
                pps = 100;
        isc_time_now(&end);
 
-       interval = 1000000 / pps;
+       interval = 1000000 / pps;       /* interval in usec */
        if (interval == 0)
                interval = 1;
        usecs = isc_time_microdiff(&end, start);
        if (usecs == 0) {
+               /*
+                * We were unable to measure the amount of time taken.
+                * Double the nodes deleted next time.
+                */
                old *= 2;
                if (old > 1000)
                        old = 1000;
                return (old);
        }
-       old = old * interval;
-       old /= (unsigned int)usecs;
-       if (old == 0)
-               old = 1;
-       else if (old > 1000)
-               old = 1000;
-       return (old);
+       new = old * interval;
+       new /= (unsigned int)usecs;
+       if (new == 0)
+               new = 1;
+       else if (new > 1000)
+               new = 1000;
+
+       /* Smooth */
+       new = (new + old * 3) / 4;
+       
+       isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_CACHE,
+                     ISC_LOG_INFO, "adjust_quantum -> %d\n", new);
+
+       return (new);
 }
                
 static void